Call periodically function with Dojo
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.
精彩评论