title: Game project updating database using ajax
body: <p>Im trying to make a realtime game with no page refresh.
  The problem is that i dont know what to do next or how to configure ajax script to update the mysql database when the player is movine over the map.</p>
  
  <p>Here is the ajax code im trying to use.</p>
  
  <pre><code>     //calling ajax to update player location when he move around
          function send(url){
  var request;
  try{
      request= new XMLHttpRequest();
  } catch (e){
      try{
          request= new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
          try{
              request= new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e){
              alert("Your browser broke!");
              return false;
          }
      }
  }
  request.onreadystatechange = function(){
      if(request.readyState == 4){
          //I dont know what to add here :-(
      }
  }
  request.open("GET", url, true);
  request.send(null);
  }
  send("update_location.php?newX="+ toX + "&amp;newY=" + toY)
  </code></pre>
  
  <p>update_location.php</p>
  
  <pre><code>  &lt;?php
  $new_x=$_GET['newX'];
  $new_y=$_GET['newY'];
  //echo"$new_x , $new_y";
  $update_loc=mysql_query("UPDATE users SET location_x='$new_x' WHERE username='admin'");
  ?&gt;
  </code></pre>
  
  <p>The main ideea is that when the player moves anywhere over the map the ajax updates new x and y values into the database.I dont need any button or jquery code added,i think ajax will work fine if somebody get me a hand doing this.</p>
  
  <p><strong>P.S. toX and toY are javascript vars wich i transformed to php vars so i can update them to mysql datavase.If somebody could help me do this i would really appreciate!</strong></p>