views:

195

answers:

2

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 constantly be updating. I'm not sure how I would be able to keep a timer's correct value when that happens.

Thanks!

+1  A: 

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.

Alan Storm
A: 

I solved the issue by using a timestamp instead of a timer. Thanks!

James