The behavior you mention in your question is by design, and is due to $.when()
only creating its own master promise when it receives more than one argument.
Non-deferred arguments, however, are considered as resolved promises returning these arguments. Therefore, you can systematically pass null
as an extra argument to $.when()
, like for instance:
$.when.apply($, [null].concat(array_ajax_calls)).then(...)
If you do that, the response in your then()
callback will always be of the form:
[
null,
[Array[1] , "success", Object],
...
]
From there, you only would have to ignore the first element and process all the others.