Prototype - AJAX PeriodicalUpdater() Method
This AJAX method periodically performs an AJAX request and updates a container's contents based on the response text.
Containers are specified by giving IDs of the HTML elements like division or paragraphs. See example below.
Callbacks are called at various points in the life-cycle of a request, and always feature the same list of arguments. They are passed to requesters right along with their other options.
new Ajax.PeriodicalUpdater(container, url[, options]);
There are two more options specific to this method −
Default value is 2.
This is the minimum interval at which AJAX requests are made.
Default value is 1.
This controls the rate at which the request interval grows when the response is unchanged.
Returns AJAX PeriodicalUpdater object.
Disabling and Enabling a PeriodicalUpdater
You can pull the brake on a running PeriodicalUpdater by simply calling its stop method. If you wish to re-enable it later, just call its start method. Both take no argument.
Here is the content of timer.cgi script −
#!/usr/bin/perl print "Content-type: text/html\n\n"; $datetime = localtime; print $datetime; print "<br />";