title: When sending multiple XMLHttpRequests only the last request returns success
body: <p>I have a page that dynamically creates (using jQuery) Input boxes for the user. The user can then enter values in each input box he created. On clicking the save button a call is made to a javascript function that iterates through all the input boxes user created and sends these values using an XMLHttpRequest to the process.php file which inserts these values into the DB. </p>
  
  <p>This code works fine if i send only one Request at a time. But if i loop it and send the value from each box on each iteration (means, send multiple requests using loop), only the last Request finds success. All the other calls except the last call gets aborted (found it using firebug).</p>
  
  <p>Any idea why is this happening?</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;script&gt;
  function saveTimeSlots(){
      var ajaxRequest;
      try{
          ajaxRequest = new XMLHttpRequest();
      }
      catch(e){
          alert('Issue with browser.')
      }
      ajaxRequest.onreadystatechange = function(){
          if( ajaxRequest.readyState==4 ){
              alert(ajaxRequest.responseText); //This returns empty except for last call
          }
      }
      var timeSlots = document.getElementById('formSlots').childNodes;
      var date = $.datepicker.formatDate('dd-mm-yy', new  Date($('#datepicker').datepicker("getDate")));
      for(j=0; j&lt;timeSlots.length; ++j){
          var time = timeSlots[j].getElementsByTagName("input")[0].value;
          var status = 1;
          var queryString = "?date=" + date + "&amp;time=" + time + "&amp;status=" + status;
          ajaxRequest.open("GET", "process.php" + queryString, true);
          ajaxRequest.send(null);
      }
  }
  &lt;/script&gt;
  &lt;input type="button" value="Save time slots" class="custom-button" onclick="saveTimeSlots()"/&gt;
  </code></pre>
  
  <p>Following is the code of process.php</p>
  
  <pre><code>&lt;?php
  mysql_connect( $dbhost,$user,$pwd );
  mysql_select_db( $dbase ) or die( mysql_error() );
  
  $date = mysql_real_escape_string( $_GET['date'] );
  $time = mysql_real_escape_string( $_GET['time'] );
  $status = mysql_real_escape_string( $_GET['status'] );
  
  $query = "INSERT INTO time_slots (`date`,`time`,`status`) VALUES ('" . $date . "','" . $time . "'," . $status . ")";
  echo $query;
  if( mysql_query( $query ) ){
      echo "Success";
  }else{
      echo mysql_error();
  }
  mysql_close();
  }
  ?&gt;
  </code></pre>
  
  <p>This is what Firebug shows:</p>
  
  <pre><code>GET http://localhost/process.php?date=24-06-2012&amp;time=1&amp;status=1 Aborted
  GET http://localhost/process.php?date=24-06-2012&amp;time=2&amp;status=1 Aborted            
  GET http://localhost/process.php?date=24-06-2012&amp;time=3&amp;status=1 200 OK 31ms
  </code></pre>