I would like to execute an Ajax request every seconds. My next code work perfectly.
window.onload = function () {
setTimeout(doStuff, 1000); //wait before continuing
}
function doStuff() {
$.ajax({
// ...
});
setTimeout(doStuff, 1000);
};
But at this moment if I use a tool like Fiddler to block my request the system continues to send new Ajax request. I would like to queue them and send my next Ajax request only after the answer of my server. How can I do that ?
Call the setTimeout inside the success callback: