General Question

Ramnath's avatar

Ajax.PeriodicalUpdater update every second and work real time?

Asked by Ramnath (2points) March 23rd, 2009

I’m using the following code in conjunction with the Prototype library:

new Ajax.PeriodicalUpdater ( “activity”,” activity.output.php”, { method: “get”, frequency: 1 } );

and was wondering if there’s any way to prevent the PeriodicalUpdater from processing the update every second and work real time.
I am trying to use new Ajax.PeriodicalUpdater to count the timing from 60 seconds to 0. So basically I want to reducing the timing by 1 second.
When I use this, the time is reducing by 1 seconds but sometime it has reduce by 2 seconds so it is not accurate and it is not always reducing by 1 seconds. So is there is anyone can help me to fix this problem?

e.g. it has to be like below
60,59,58,57,56,55,54,53,52,51,50 and so on

But the Ajax.PeriodicalUpdater sometime work like below.
60,59,57,56,55,53,51,50 and so one

So as you see it not count accuracy and itmissed 58,54,52 and this curry on until time is over. I believing there is some sort of soluation. If anyone can help me I really appreciate.

ref: http://www.prototypejs.org/api/ajax/periodicalUpdater

Thank you advance.

Observing members: 0 Composing members: 0

2 Answers

phoenyx's avatar

Sounds like you want a TimedObserver instead.

funkdaddy's avatar

Is there any reason it needs to be AJAX as opposed to just straight javascript? Are you actually returning anything?

Do a google search for “javascript countdown” and you’ll find quite a few examples of different ways to do this if nothing is being returned.

A couple discussion of the same thing to get you started
http://refactormycode.com/codes/302-countdown-timer-minutes-seconds-javascript
http://www.sitepoint.com/forums/showthread.php?t=605683

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther