title: jQuery deferreds - order of execution in multiple blocks
body: <p><strong>NOTE</strong><br>
  <em>This problem somehow happens only with a specific server-side api. Therefore it addresses the wrong problem. I'll not delete it since it have answers and comments.</em></p>
  
  <hr>
  
  <p>I'm trying to execute a few ajax requests, do some stuff after each is done and some other stuff after all of them are done, for that I'm using the code below:</p>
  
  <pre><code>let
          myarr = [],
          myfunc = arg =&gt; myarr.push(arg);
  
  $.when(
      $.post(myparams).done(myfunc),
      $.post(otherparams).done(myfunc),
      $.post(yetanother).done(myfunc)
  
  // it comes out with only one arg
  ).then(e =&gt; console.log(myarr));
  </code></pre>
  
  <p>But when it comes to execute the <code>then</code> block it usually has only executed the <code>done</code> of the first operation, how could I fix that?</p>
  
  <p>I'm sorry if it's a duplicate but honestly I didn't even knew what to search for :/</p>
  
  <hr>
  
  <p><strong>Comment</strong>  </p>
  
  <p>I also tried to create my own deferreds where I would execute the ajax and resolve them inside the <code>done</code> block, but that yielded the same results.</p>
  
  <p>Using only <code>done</code> or only <code>then</code>, same.</p>