Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>var i = window.setInterval( function(){ ajaxUpdate(10); }, 1000 ); </code></pre> <p>This will call ajaxUpdate every second, until such a time it is stopped. </p> <p>And if you wish to stop it later: </p> <pre><code>window.clearInterval( i ); </code></pre> <p>If you wish to only run it <em>once</em> however, </p> <pre><code>var i = window.setTimeout( function(){ ajaxUpdate(10); }, 1000 ); </code></pre> <p>Will do the trick, and if you want to stop it running before it gets around to running once</p> <pre><code>window.clearTimeout(i); </code></pre> <p>The "window" prefix is not strictly nessecary, but its a good idea, because you never know when somebody else might like to create something else with the same name in visible scope that behaves differently. </p> <p>For a complete reference on this, I always find MDC Very Helpful: </p> <ul> <li><a href="https://developer.mozilla.org/en/DOM/window.setInterval" rel="noreferrer">MDC: window.setInterval</a></li> <li><a href="https://developer.mozilla.org/en/DOM/window.clearInterval" rel="noreferrer">MDC: window.clearInterval</a></li> <li><a href="https://developer.mozilla.org/en/DOM/window.setTimeout" rel="noreferrer">MDC: window.setTimeout</a></li> <li><a href="https://developer.mozilla.org/en/DOM/window.clearTimout" rel="noreferrer">MDC: window.clearTimeout</a></li> </ul> <p>Also, you may wish to read this article on timers by John Resig, </p> <ul> <li><a href="http://ejohn.org/blog/how-javascript-timers-work/" rel="noreferrer">ejohn.org : How Javascript Timers work </a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload