jQuery 时间函数
你好,我有这段 jQuery 代码
jQuery(document).ready(function($) {
$.get("<?echo $site['url'];?>modules/tuitting/tuitting_core/classes/count.php", function (data) {
var resultDiv = document.getElementById('count');
resultDiv.innerHTML = data;
});
});
现在我需要的是让这个函数持续检查数据,即使页面没有刷新。我想我应该使用jquery计时功能,但我根本不了解jQuery,我迷失了。谁好心给我代码啊?我们将非常感激。谢谢!
Hello I have this snippet of jQuery code
jQuery(document).ready(function($) {
$.get("<?echo $site['url'];?>modules/tuitting/tuitting_core/classes/count.php", function (data) {
var resultDiv = document.getElementById('count');
resultDiv.innerHTML = data;
});
});
Now what I need is to make this function continuosly checking the data, even when the page is not refreshing. I think I should use a jquery timing function, but I do not really know jQuery at all, and I am lost. Who is so nice to provide the code to me? That would be VERY appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将其放入带有
setTimeout
的函数中:put it in a function with
setTimeout
:您应该做的是将其放在一个时间间隔上:
这将每 2000 毫秒调用一次定义的回调。在您的阅读事件中,您只需开始间隔:
What you should do is put this on an interval:
This will invoke the callback defined every 2000 milliseconds. In your read event, you simply start the interval: