The code creates an array of pending messages representing AJAX ( dfdArr) requests and populates it while.
Then it is applyused on $.when, so that all these deferred are passed to it as arguments. This leads to the return of the promise, which ends when all the initial deferrals were successful, i.e. When all AJAX requests have returned.
In other words, a call applyis the software equivalent of a record
$.when(dfdArr[0], ..., dfdArr[qty_of_gets - 1]).done(...);
source
share