I'm building a polling sort of system to notify people if there is already someone in a particular page/field and would like to run a ping on that particular page/field to check if person is still sitting in there.
Given javascript:
function initialiseTrackPing(trackId) {
var loopCounter = 1;
//while (true) {
setTimeout(function() {
console.log(loopCounter++);
iCommon.Ajax.unCloseTrack(trackId);
}, 5000);
//}
}
So I've commented the while loop out as it causes the whole browser to crash as the timeout seems not to cause the script to wait, so it loops to infinite as I suppose.
Inside the unCloseTrack(...) function there is an ajax call that will do some server-side work which I call asynchronous.
My Question:
How can I get the script not looping like crazy and just do so every 5000ms?
Thanks