title: Queue multiple AJAX requests, waiting for response and not freezing browser?
body: <p>I am working a script, I need to loop an array of AJAX requests:</p>
  
  <pre><code>$('#fetchPosts').click(function(){ 
  
      for(var i=0; i &lt; link_array.length; i++) {
  
          settings = {
             // some object not relevant
          }
  
          var status = main_ajaxCall(settings, i); // ajax call
       }
  });
  
  function main_ajaxCall(settings, i) {
  
     $.ajax({ 
       type: "POST",
       url: "../model/insert.php",
       data:{obj_settings: settings},
       dataType: "json",
       cache: false,
       success: function (data) {
           // some handeling here
           return 0;
       },
       error: function(XMLHttpRequest, textStatus, errorThrown) {
           return 1;
       },
  };
  </code></pre>
  
  <p>Why does the AJAX requests fire instantly? It does not seem to wait for a response from model/insert.php, is there any way to force it to wait for a response before firing the next AJAX request?</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>It seems I wasnt clear, sorry, I dont want it to wait, I want to queue up the calls.</p>
  
  <p>I cant make the call in one request, this is impossible in my current situation.</p>