开发者

Call periodically function with Dojo

开发者 https://www.devze.com 2023-02-17 23:05 出处:网络
I need to update data on my site every 1000ms. How to ca开发者_如何学Cll function periodically with Dojo ?You might want to have a look at setInterval().

I need to update data on my site every 1000ms. How to ca开发者_如何学Cll function periodically with Dojo ?


You might want to have a look at setInterval().

The function takes a function and a number as parameters. The function is called every n milliseconds where n is the second parameter.

For example:

var timer = setInterval(function() {
    alert('called every 2000 milliseconds');
}, 2000);

To stop the interval you will have to call clearInterval()

clearInterval(timer);

Or if you just want to run something after n milliseconds make a call to setTimeout()

setTimeout(function() {
    alert('also called after 2000 milliseconds BUT, just once');
}, 2000);

Hope this helped.

0

精彩评论

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