$.Deferred: How to detect when every promise has been executed
问题 I have a number of async tasks that need to be completed, so I\'m using promises. I need to detect when each one of the promises has been executed (both resolved and rejected). I must not continue execution until that point. I was using something like this: $.when(promise1, promise2, ...).always(); But this code is wrong, because the when method has lazy evaluation, and it returns as soon as one of the promises fails. So the always callback also runs as soon as one of the promises fail. I was