title: Multiple Ajax run syncronus in .each loop
body: <p>I want to run AJAX requests for multiple time to get data from different folders and at the last one more AJAX will fire to make a zip of the data.
  every thing is done but the biggest issue is some files runs after the file file run so they can't be include in zip file.
  Please suggest what to do?</p>
  
  <pre><code>$('#View_Rep').click(function() {
      $(this).hide();
      $('#restable').hide();
      document.adminweeklycorrection.action = '';
      $('#centerSec').css('display', 'none');
      $('#processingDiv').css('display', 'block');
      $('#processingDiv').html("&lt;img height='150' src='img/loading-circle.gif'&gt;&lt;h4&gt;Processing data&lt;/h4&gt;");
      var carr = $('#wkarr').val();
      carr = carr.split(",");
      $.each(carr, function(n) {
          if ($('#weekarray').val()) {
              $.ajax({
                  url: "rxml.php",
                  method: "POST",
                  async: "false",
                  data: $("#adminweeklycorrection").serialize()
              }).done(function(msg) {
                  if (n == parseFloat(carr.length) - parseFloat(1)) {
                      $('#processingDiv').html("&lt;img height='150' src='img/loading-circle.gif'&gt;&lt;h4&gt;Preparing reports&lt;/h4&gt;");
                      $.ajax({
                          url: "cmbrxml.php",
                          method: "POST",
                          async: "false",
                          data: $("#adminweeklycorrection").serialize()
                      }).done(function(msg) {
                          $('#processingDiv').html("&lt;h3&gt;Report generated successfully&lt;/h3&gt;&lt;h4&gt;&lt;a href='" + msg + "'&gt;Download Report&lt;/a&gt;&lt;/h4&gt;&lt;h5&gt;&lt;a href='adminchartcorrection.php'&gt;Back&lt;/a&gt;&lt;/h5&gt;");
                          if ($('#logtype').val() == 'Ship') {
                              $('#processingDiv').append("&lt;form name='send_mail' id='send_mail' method='post' action='adminchartcorrection.php'&gt;&lt;input type='hidden' name='chartnumber' id='chartnumber' value='" + $('#chartnumber').val() + "'&gt;&lt;input type='submit' name='send_mail' value='Send Mail' id='send_mail'&gt;&lt;/form&gt;");
                          }
                          //redir(msg);
                      });
                  }
              });
              var curr = $('#weekarray').val();
              curr = curr.split(",");
              var sftd = curr.shift();
              //$('#weekarray').val('');
              $('#weekarray').val(curr);
          }
      });
  });
  </code></pre>