title: Synchronous POSTing to SQL handle using AJAX
body: <p>I wish to make a synchronous call to a page that handles SQL insert of the words I'm posting. However since I have many chunks and SQL is not asynchronous I wish to process each ajax call/chunk after another</p>
  
  <pre><code>for (chunk = 1; chunk &lt;= totalchunks; chunk++) {
      $.ajax({
      type: "POST",
      dataType: "json",
      url: "updateHandle.php", 
      data: {words:arr.slice(1000*(chunk-1),1000*chunk),push:getpush},
      success: function(){
          console.log('Items added');
      },
      error: function(){
          console.log('Errors happened');
      }
      });
  }
  </code></pre>
  
  <p>the</p>
  
  <pre><code>async: false,
  </code></pre>
  
  <p>does not work for some reason. Each ajax call always goes to the error case and not the success case. So is there another solution to this issue that I've overlooked? </p>
  
  <p>I thought about using a busy-waiting while-loop and use locks, but the setTimeout() function does not work as expected (probably some error on my part)</p>
  
  <p>EDIT: The chunks are too big for one AJAX call hence serialization is needed. Also the amount of chunks may change from call to call, so flexibility is needed. </p>