<?
if($_GET['test'])
{
echo "You Said: ".$_GET['test']."";
sleep(1);
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajax</title>
<script>
function doWork(){
if (window.ActiveXObject)
httpObject = new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
httpObject = new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
httpObject = null;
}
if (httpObject != null) {
httpObject.open("GET", "index.php?test=hello", true);
httpObject.send(null);
httpObject.onreadystatechange = function()
{
if(httpObject.readyState == 4){
document.getElementById('outputText').innerHTML = httpObject.responseText;
}
};
}
}
</script>
</head>
<body>
<input type="button" value="Send" onclick="doWork()" />
<div id="outputText"></div>
</body>
</html>