title: Jquery AJAX promise with always break when ajax fail
body: <p>I have a loop with multiple ajax request.
  each ajax is managed thru always callback.
  each ajax is pushed in promises array.
  finally $.when is used on always.</p>
  
  <p>If all <code>$.ajax</code> got success the <code>$.when.apply($, promises).always(...);</code>
  is called when all <code>$.ajax</code> calls succeed.</p>
  
  <p>But for example on 3 <code>$.ajax</code> call the second fails, the <code>$.when.apply($, promises).always(...);</code> is fired only after the second and not when all <code>3 $.ajax</code> calls suceed.</p>
  
  <p>Any help?
  Following the code</p>
  
  <pre><code>$(".upload_all").bind("click", function() {
    var confirmed_count = 0;
    var error_count = 0;
    var promises = [];
  
    to_uploads.each(function(index,val) {
      var elem = $(this);
      var promise = $.ajax({
        url: "/upload/storeUploadedFile",
        type: 'POST',
      }).always(function(data_or_jqXHR, textStatus, jqXHR_or_errorThrown) {
        if (textStatus === "success") {
          // ..
        } else {
          // ..
        }                  
      });
  
      promises.push(promise);
    });
  
    $.when.apply($, promises)
      .always(function() {
        console.log("Promises Always! ") // do other stuff
      });
  }
  </code></pre>