如何在jquery中自动滚动到底部并自动刷新

问题描述:

我正在使用此jquery ajax从数据库接收消息。但是当有人试图发送一个消息然后它来到这里但无法自动滚动到底部。任何的想法?

I am using this jquery ajax to receive msg from the database. But when someone trying to send a msg then it's coming here but could not auto scroll to the bottom. Any idea?

  setTimeout(startRefresh,1000);
var myKeyVals = { some value };

        var saveData = $.ajax({
          type: 'POST',
          url: "https://example.php",
          data: myKeyVals,
          success: function(resultData) { 
            $("#chatwindow").html(resultData);
            //######################################
          }
      });
      saveData.error(function() { alert("Something went wrong"); });


你可以尝试这个技巧。看看这是否对你有所帮助:

You can try this trick. See if this helps you:

$("html, body").animate({ scrollTop: $(document).height() }, 20000);
setTimeout(function() {
   location.reload();
},20000);