Best practice for Polling in JavaScript using setTimeout

function refresh() {
    // make Ajax call here, inside the callback call:
    setTimeout(refresh, 5000);
    // ...
}

// initial call, or just call refresh directly
setTimeout(refresh, 5000);

References
https://stackoverflow.com/questions/8682622/using-setinterval-to-do-simplistic-continuous-polling

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.