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