You must wait for all deferred objects to finish.

var defTimerOneQuestion = []; $.when.apply($, defTimerOneQuestion).then(function () { finish(); }); 

Add deferred objects to the array;

 var defCurrentTimerOneQuestion = new $.Deferred; defTimerOneQuestion.push(defCurrentTimerOneQuestion); setTimeout(function () { defCurrentTimerOneQuestion.resolve(); return defCurrentTimerOneQuestion.promise(); }, 20000); 

But deferred doesn't shoot, what could be the problem?

  • in that it is necessary to fold the promises - Grundy
  • Replaced with defTimerOneQuestion.push (defCurrentTimerOneQuestion.promise ()); But it still doesn't work - Denis Bozhkov
  • one
    The problem is that $.when must be called when all promises are already folded into an array, and not in advance. - Pavel Mayorov

0