1

滑完后我有奇怪的内容闪现。我添加了:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

到我的代码的开头,但是整个页面都在跳转,发生下滑

我的解决方案是什么?

这是我的代码以防万一:

$("#contentbottom").slideUp(500, function() {
var dataString = 'type='+t;
$.ajax({
    type: "POST",
    url: link,
    data: dataString,
    success: function(msg)
    {
        $("#contentbottom").empty().append(msg);
    },
    error: function (XMLHttpRequest, textStatus, errorThrown)
    {
        alert('error: unable to load the additonal info');
    },
    complete: function()
    {
        $("#contentbottom").slideDown(500);
    }
});
});
4

1 回答 1

0

My guess, without seeing any of your markup, is that $("#contentbottom").empty().append(msg); is populated with the AJAX response causing your browser to flash/scroll down to the new content, then back up to the top.

If you don't have any CSS styles to hide the #contentbottom element when it's empty, that might be a part problem. Yu could just do $('#contentbottom').hide() in your slideUp handler before you AJAX call, then $("#contentbottom").empty().append(msg).show() in the success handler...

于 2012-10-16T17:49:47.763 回答