Having a really hard time with this issue, and I know $.when() can be used like so (with multiple AJAX statements) to promise you when they have all finished.
$.when(
$.ajax({ url: '/echo/html/', success: function(data) {
alert('request 1 complete')
}
}),
$.ajax({ url: '/echo/html/', success: function(data) {
alert('request 2 complete')
}
})
).then( function () { alert('all complete'); });
But this only works with raw $.ajax(), is there anyway to have this same functionality with function calls, that in turn have the ajax inside them (and other random logic) ?
Pseudo-code idea:
// The functions having the AJAX inside them of course
$.when(ajaxFunctionOne, ajaxFunctionTwo).then(function () {
alert('all complete');
});
Sure, have the function return a promise object.