Here is a test page made out of your script, which works:
Code:
<html>
<head>
<script type="text/javascript">
var xmlhttp;
function doajax(theURL) {
var params = 'param1=test¶m2=test2'
xmlhttp=new XMLHttpRequest()
xmlhttp.open("POST",theURL,true)
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange= function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
alert(xmlhttp.responseText)
};
xmlhttp.send(params)
}
</script>
</head>
<body>
<button onclick="doajax('ajtest1.php');">ajax text</button>
</body>
</html>
Code:
<?php
echo "response: param1=" . $_POST['param1'] . ", param2=" . $_POST['param2'];
?>
Bookmarks