如何在jquery中自动滚动到底部并自动刷新 [英] How to auto scroll to bottom with auto refresh in jquery

查看:90
本文介绍了如何在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);

这篇关于如何在jquery中自动滚动到底部并自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆