repeat executung script
Use
setInterval
to automatically call the specified function periodically:var interval = setInterval(function() { // do ajax request ............... }, 60 * 1000); if (some_condition) { clearInterval(interval); // stop the timer }
Use
setTimeout
to schedule one run of the function based on condition:var timeout; (function doAjax() { // do ajax request ............... if (some_condition) { timeout = setTimeout(doAjax, 60 * 1000); // schedule the next run } })(); if (another_condition) { clearTimeout(timeout); // cancel the schedule }
thank you wOxxOm!, you are good for a teacher :D
repeat executung script
hi, for example i have a ajax request, how i can repeat the request every 1 minute? thank you.