Welcome to the Cookbook

loading...

7.1.2.3 remoteTimer

remoteTimer(array $options)

Periodically calls the action at $options['url'], every $options['frequency'] seconds. Usually used to update a specific div (specified by $options['update']) with the result of the remote call. Callbacks can be used.

remoteTimer is the same as the remoteFunction except for the extra $options['frequency']

Example:

<div id="post">
</div>
<?php
echo $ajax->remoteTimer(
	array(
	'url' => array( 'controller' => 'posts', 'action' => 'view', 1 ),
	'update' => 'post', 'complete' => 'alert( "request completed" )',
	'position' => 'bottom', 'frequency' => 5
	)
);
?>
  1. <div id="post">
  2. </div>
  3. <?php
  4. echo $ajax->remoteTimer(
  5. array(
  6. 'url' => array( 'controller' => 'posts', 'action' => 'view', 1 ),
  7. 'update' => 'post', 'complete' => 'alert( "request completed" )',
  8. 'position' => 'bottom', 'frequency' => 5
  9. )
  10. );
  11. ?>

The default $options['frequency'] is 10 seconds