开发者

jQuery Time Refresh

I am using the jQuery countdown timer at http://keith-wood.name/countdown.html

I am trying to get the time remaining to refresh automatically without reloading the page. It is getting the remaining t开发者_C百科ime from a MySQL DB and if I change the value in the DB the time still countdowns from the original time. I have an onTick event which checks a script for the new time.

If I use the destroy command the script attaches multiple times for every onTick.

Is there a way to reinitialize the timer without reload?

Cheers


Seems it should be no problem to just go:

$("#timer").countdown("destroy").countdown({ until: newDate, onTick: checkTime });

It works here: http://jsfiddle.net/YA4BW/. Note that the tick counter still only increments by one per second after the timer has been destroyed and re-initialized. When you initialize the timer, the first onTick event is immediate, so you will effectively get a second onTick event for the same second when you re-initialize.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜