I've developed a function that retrieves records from a third party, and this function runs every 10 seconds. However, as I debug through Firefox, I notice a long queue of ajax requests. I'm contemplating including a statement that can signal to the next request about ongoing ajax executions. Since the function and its purpose remain the same with each execution, it seems redundant to trigger another one if the previous one is still processing. Here's what I've attempted:
function checkExecution(){
if(sessionStorage.do == true){
$.ajax(function(){
continue...
});
}
sessionStorage.do = true;
sessionStorage.do = false;
}
setInterval(checkExecution, 10000);
Unfortunately, the above approach is not working as intended. Could someone offer guidance on how to achieve this? I would greatly appreciate it.