开发者

How to call .post() in a given time interval?

开发者 https://www.devze.com 2023-01-31 00:57 出处:网络
I would like to update some <div> in a given time interval. Let say every 3 seconds call mypost() fun开发者_开发问答ction.

I would like to update some <div> in a given time interval. Let say every 3 seconds call mypost() fun开发者_开发问答ction.

How to do that in jquery?

Thanks Arman.


There's nothing in jquery that allows you to do this because there's the native javascript window.setInterval function:

window.setInterval(function() {
    // this will be invoked on every 5s
    $.post(...);
}, 5000);

If you want to invoke it only once:

window.setTimeout(function() {
    // this will be invoked after 5s only once
    $.post(...);
}, 5000);
0

精彩评论

暂无评论...
验证码 换一张
取 消