I have two functions which has ajax calls
inside them.
function a(){
ajaxCall_A();
}
function b(){
ajaxCall_B();
}
And I
You need to synchronize both of them using a semaphore
function c(){
$semaphore=true;
a();
while($semaphore ) {
setTimeout("checksemaphore()", 500);
}
b();
// expectation : function 'b' will get executed only after function 'a' finished it's execution
}
inside the ajax call to a
add a complete:
complete : function(result) {
$waitsemaphore= 0 ; },
error: function(result) {alert("AJAX completed w/error");alert(result);},