Up until now I have been using:
xmlhttp.open("GET","server_script.php?q="+str,true);
Thanks
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 http://www.w3schools.com/PHP/php_ajax_php.asp using the GET method first.
Solution-
javascript:
xmlhttp.open("POST","script.php",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send('var_name='+str);
php:
$var_name = GET['var_name'];
echo $var_name;
For reasons regarding the use of POST and GET - see comments blow.