You could define one, two or three update functions (depends on what you want to do) that take the response of the corresponding promises (ajax callbacks):
function bindPromises(updateSuccess, updateFail, updateAnyway) {
var arrPromises = [];
// automate the promise retrieval if you want, that's up to you.
arrPromises[0] = ajaxRequest1();
arrPromises[1] = ajaxRequest2();
arrPromises[2] = ajaxRequest3();
arrPromises[3] = ajaxRequest4();
arrPromises[4] = ajaxRequest5();
for(var j = 0; j < arrPromises.length; j++) {
arrPromises[j].then( updateSuccess, updateFail, updateAnyway );
}
}
Or if you want to automate even more:
function bindPromises(arrayOfAjaxCalls, updateSuccess, updateFail, updateAnyway) {
var arrPromises = [];
for(var i = 0; i < arrayOfAjaxCalls.length; i++) {
arrPromises[i] = (arrayOfAjaxCalls[i])();
arrPromises[i].then( updateSuccess, updateFail, updateAnyway );
}
}
If you're not familiar with Promises I would like to point you to a great article covering that topic: Understanding jQuery.Deferred and Promise