multiple ajax success callback defer
In my javascript, I have the following scenario:
call_A(success_A)
call_B(success_B)
fucntion call_A(success){
// make ajax request
success(result)
}
function call_B(success){
//make ajax
request success(result)
}
function success_A(){
//set data to be used by success_B
}
function success_B(){
..do some stuff
}
I want to make both call_A and call_B one after the other so that ajax calls are made (to save time).
I do not have the option for changing call_A and call_B function headers, so the call to these function has to be made specifying the success callback function.
What I want is that regardless of which of the 2 ajax call finishes first, I want success_A get called before success_B, because B depends on A's data. What is the best way of getting this done?