title: Sending multiple objects using javascript and ajax to php
body: <p>I've created code that takes an object and sends it from one web page, in javascript, to another. 
  I use Ajax and the POST method to send the object, and I currently use POST on the second page to get the data in PHP and send it back to a database.
  Currently it works when I try send one object, but I'm trying to find a way to send multiple objects in one go.</p>
  
  <p>I'm trying to use a for loop, I loop through an array containing the objects and attempt to send one at a time.
  Currently only the first item in the array makes its way to the database and I'm unsure why.</p>
  
  <p>Below is the code using Ajax to send:</p>
  
  <pre><code>        for (i = 0; i &lt; objSend.length; i++) {
              //objSend is the array containing the objects
              console.log("i",i);
              console.log(objSend[i]);
  
              $.ajax({
                  async: false,
                  type: "POST",
                  url : "map_process_test.php",
                  data: objSend[i],
                  success : function(data){
                      console.log("Sent/Done");
                  },
                  error: function(xhr,ajaxOptions,thrownError){
                      alert(thrownError);
                  }
  
              });
  
  
          }
  </code></pre>
  
  <p>The console returns "Sent/Done" every time, but nothing else is found in the database.
  Below is the code from the second page that receives the data </p>
  
  <pre><code>$lat = $_POST["pin_lat"];
      $lng = $_POST["pin_lng"];
      $pin_id = $_POST["pin_id"];
      $pin_number = $_POST["pin_number"];
      $pin_text = $_POST["pin_text"];
      $pin_title = $_POST["pin_title"];
      $project_id = $_POST["project_id"];
  
  
      $results = mysql_query("INSERT INTO tbl_project_coords(pin_id, pin_number, pin_lat, project_id, pin_lng, pin_title, pin_text) VALUES ('$pin_id','$pin_number','$lat','$project_id','$lng','$pin_title','$pin_text')");
      echo("DONE 2 ");
  </code></pre>
  
  <p>I've tried using Async set to both true and false, and neither has made a difference.
  Thanks for any help</p>