title: PHP get value from AJAX
body: <p>I had an ajax implementation below and it working fine. Now, how can I get distance and id in toDistance.php? I had my code pasted below and does not add the data into my database. What is wrong?</p>
  
  <pre><code>function getABC(){
  for(s=0;s&lt;length;s++){
      volunteerlocation = new GLatLng(jlat[s], jlng[s]);
      volunteerDist[s] = (Math.round((eventlocation.distanceFrom(volunteerlocation) / 1000)*10)/10);
      document.write(volunteerDist[s] + '&lt;br&gt; ');
      document.write(jid[s] + '&lt;br&gt; ');
  }
  
  alert(Object.prototype.toString.call(volunteerDist));
  
   $.ajax({
      type:'POST',
      url: 'toDistance.php',
      data : ({
          distance:volunteerDist,
          id:jid
      }),
      success: function(data){
           alert(data);
           alert('worked');
      },
     error :function(jqXHR, textStatus, errorThrown) {
          alert(errorThrown);
      },
     complete : function(){
         alert('thanks');
     }
  });
  }
  </code></pre>
  
  <p>Below is my toDistance.php</p>
  
  <pre><code>&lt;?php
      $distance=array();
      $volunteerid=array();
      if(empty($_GET)){
  
      }
      else{
  
          $distance = isset($_GET['distance']) ? $_GET['distance'] : 0;
          $volunteerid = isset($_GET['id']) ? $_GET['id'] : 0;
          $connect = mysql_connect("localhost","root","");
          mysql_select_db("mapping");
  
  
          for($i=0;$i&lt;$distance.length;$i++){
              $updateDistance = mysql_query("
              UPDATE volunteerbio
              SET volunteerDistance = $distance[$i]
              WHERE volunteerID = $volunteerid[$i];
              ");
          }
      }
  ?&gt;
  </code></pre>