I need to loop asynchronous calls, but they can not run simultaneously, I have to wait for the end to run another. I just do not have control over this call ( It's a js function Sharepoint CSOM ).
So I at the beginning of my idea is just to detect if a call is already running. If it is running I will test again until there is no more call running, and then yes I continue the loop.
More or less the idea:
function chamarAjax(){
blablabla();
if(blablabla()){
continuarLoop = false;
}
}
if(!ajaxIsRunning){
if(continuarLoop){
chamarAjax();
}
}