Javascript 每次重新加载数据时向上滚动

Javascript 每次重新加载数据时向上滚动,javascript,ajax,Javascript,Ajax,这是我的代码: var j = jQuery.noConflict(); j(document).ready(function() { j("#refresh").everyTime(3000, function(I) { j.ajax( { url: "refresh.php", cache: false, success: function(html) {

这是我的代码:

var j = jQuery.noConflict();

j(document).ready(function()
{
    j("#refresh").everyTime(3000, function(I)
    {
        j.ajax(
        {
          url: "refresh.php",
          cache: false,
          success: function(html)
          {
              j("#refresh").html(html);     

              var newscrollHeight = j("#refresh").attr("scrollHeight") - 20;

              j("#refresh").animate({scrollTop: newscrollHeight },      'normal'); //scrol otomatisnya                      

          }
        });
    });     
});

我想向上滚动我的滚动条,但无法,因为刷新每3000次重新加载一次。有人知道如何解决这个问题吗?

我会用不同的方法,如果需要,在滚动到顶部后,让成功处理程序在3秒钟后调用相同的方法

试着这样做:

var j = jQuery.noConflict();

j(document).ready(function()
{
      Refresh();
});     

function refresh()
{
    j.ajax(
    {
      url: "refresh.php",
      cache: false,
      success: function(html)
      {
          j("#refresh").html(html);     

        //  var newscrollHeight = j("#refresh").attr("scrollHeight") - 20;
         // j("#refresh").animate({scrollTop: newscrollHeight },'normal'); //scrol otomatisnya   

          var div = $('#refresh');
          div.scrollTop(div.prop("scrollHeight") - 20);

          setTimeout(function()
          {
              Refresh();
          },3000);  // or how ever long     
      }
    });
}

更新:我更新了滚动代码

没有工作,我想在底部滚动。我更新了我的答案,尝试使用$'refresh'。scrollTopd.propscrollHeight-20;