title: AJAX - Using POST instead of GET
body: <p>Up until now I have been using: </p>
  
  <pre><code>xmlhttp.open("GET","server_script.php?q="+str,true);
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Edit:
  I am providing a solution for anyone that may come across this page to demonstrate how to use POST instead of GET. If you are new to AJAX I would recommend this tutorial <a href="http://www.w3schools.com/PHP/php_ajax_php.asp" rel="nofollow">http://www.w3schools.com/PHP/php_ajax_php.asp</a> using the GET method first. </p>
  
  <p>Solution-</p>
  
  <p>javascript:</p>
  
  <pre><code>xmlhttp.open("POST","script.php",true);
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.send('var_name='+str);
  </code></pre>
  
  <p>php:</p>
  
  <pre><code>$var_name = GET['var_name'];
  
  echo $var_name;
  </code></pre>
  
  <p>For reasons regarding the use of POST and GET - see comments blow. </p>