Ajax to pass variables to php?

how can I make ajax pass variables to php, I been trying to use $POST but it´s not working for me, I have this script


function get_school_data()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("test").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST","select2.php",true);
xmlhttp.send();
}

Then I have this select field


<select id="country" name="country" onchange="get_school_data()">
<?php
mysql_select_db("coatlcalli", $con);

$ccode = mysql_query("SELECT * FROM country");
//$rs = mysql_query("SELECT enname FROM country");

while($row = mysql_fetch_array($ccode))
{
  echo "<option value=\\"".$row['ccode']."\\">".$row['enname']."\
 ";
}
?>
</select>
<p id="test"></p>

and the select2.php


<?php
$ccode=$_POST['country'];
?>

What I am trying to achieve is to send the value of country to php and have it stored in a variable so I can then select a different table in the database, but when I do it the way I am, it does not work, as it gives me an undefined variable

Any help is apreciated

Googling for “ajax post variables” gave me this example as first result: Using POST method in XMLHTTPRequest(Ajax)