Use promises and $.when :
$.when(ajaxCall1(), ajaxCall2()).then(ajaxCall3);
where ajaxCallX is something like
function ajaxCall1() { return $.ajax(...); }
This basically means "after both, the promise of ajaxCall1 and the promise of ajaxCall2 allowed, execute the function ajaxCall3 ."
This works because the object returned by $.ajax (and similar methods) implements the promise interface. See the $.ajax documentation for more details.
The responses of each Ajax call are passed in response to then as arguments. You can use them as
$.when(ajaxCall1(), ajaxCall2()).then(function(a1, a2) {
Take a look at the $.when documentation for another example.
source share