Change your client code to this
<html>
<head>
<script type="text/javascript">
function ajax()
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("response").innerHTML = xmlhttp.responseText;
}
}
var text = document.getElementById("text").value;
xmlhttp.open("GET","server.php?q=" + text, true);
xmlhttp.send();
return false;
}
</script>
</head>
<body>
<form>
<input type="text" id="text">
<button onclick="return ajax();">Send</button>
</form>
<p id="response"></p>
</body>
</html>
In your code i found your "onclick" spelling method using special character. And you should return false from javascript then use that value in your button click event so that it should post back. I changed your code and tested on my local development server and its working fine.