As our friend Rikin said above, using Q library is definitely a good choice. jQuery.when() doesn't continue the requests if any of those requests parameters fails.
Q have methods that makes this possible. Look, imagine that you have fn1 and fn3 that gives you HTTP 200 and fn2 returns HTTP 404, with this method Q.allSettled
it will work perfectly.
Q.allSettled([fn1(), fn2(), fn3()])
.then(function(f1Result, f2Result, f3Result) {
// your code that will run every time...
});
If you need to use it in your web project, follow these steps (you will need to have npm installed in your machine):
1) Go to https://github.com/kriskowal/q and clone/download the repo.
2) Then to the folder where you cloned the repo and run npm install
.
3) Finally, npm run minify
. It will generate the q.min.js and you can use in your projects.
For more info, go to Q wiki reference: https://github.com/kriskowal/q/wiki/API-Reference
Cheeers~