title: jQuery ajax in each loop
body: <p>I have a problem with getting values in success function (ajax) inside the $.each loop.</p>
  
  <p>I've got something like this:</p>
  
  <pre><code>var test = [];
  $.each(images, function(index){
      var formData = new FormData();
      formData.append('image', images[index]);
  
      $.ajax({
          url: 'http://localhost/admin/api/offers/upload_photo',
          data: formData,
          cache: false,
          contentType: false,
          processData: false,
          type: 'POST',
          beforeSend: function(){
              console.log(test.length);               
              test.push(images[index]);       
          },
          success: function(){
              console.log(test.length);
          }
      });
  });  
  </code></pre>
  
  <p>And the output of beforeSend works fine (console log: 0, 1, 2), but another one returns three times 3 (console log: 3, 3, 3). The rest works with no problems, I only struggle with it. Is there anyone who is able to help me? Thanks!</p>