开发者

Need multiple independent timers in Ajax

开发者 https://www.devze.com 2022-12-13 22:02 出处:网络
I need the ability to create up to N amount timers in JavaScript/Ajax that will count like a stopwatch(but have no buttons).

I need the ability to create up to N amount timers in JavaScript/Ajax that will count like a stopwatch(but have no buttons).

Another issue is that my data will be loaded via another Ajax request so the page will c开发者_StackOverflowonstantly be updating. I'm not sure how I would be able to keep a timer's correct value when that happens.

Thanks!


Javascript already has this functionality. Checkout the

setInterval
setTimeout

functions. Both will let you say "In x number of milliseconds, I want the following callback function to fire". With setTimeout, the callback fires once. With setInterval, the callback fires repeatedly until you tell it to stop.

0

精彩评论

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

关注公众号