Wait until array of promisses are done

Wait until array of promisses are done

I have array of some data, let's say Cities. In the loop I execute some async call (let's say to bring the streets) to get the promise. I mark the city object as done or fail depends on promise status. Once all cities' promises are done, I want to execute function that render the data depends on the status of the promise, either true or false.

Here what I have tried:
---------------------------------------------------
var promises = [];
$.each(Cities, function (key, value) {
var city = this;
var streets = .... ajax call
promises.push(streets);
streets.done(function (result) { city.succeed = true; }).fail(function () { city.succeed = false; });
});
$.when.apply($, promises).always(ShowCitiesWithStreets);










 
This scenario is partially working, when all promises are resolved. However, if at least one of the promises fails, it execute show function immediately and doesn't wait on the results of the rest promises.