<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="alihammad">
<title>Untitled 3</title>
<script type="text/javascript">
function check(name)
{
if(window.XMLHttpRequest)
{
http_request=new XMLHttpRequest;
}
else{
http_request=new ActiveXObject("Microsoft.XMLHttp");
}
http_request.onReadyStateChange= handleResponse;
url='http://localhost/php/ajax/test1.php?name='+name;
http_request.open('GET', url, true);
http_request.send(null);
}
function handleResponse(){
if(http_request.readyState == 4){
response=http_request.responseText;
e=document.getElementById("myDiv");
e.innerHTML=response;
}
}
</script>
</head>
<body>
<form name="f">
<input type="text" name="name">
<input type="button" value="Pressme" onclick="check(f.name.value)">
</form>
<div id="myDiv" style="width: 250px; float: right; background-color:gray;">No Value yet!!</div>
</body>
</html>
--------- ------------- test1.php -------------------- ---------------- - - --------
<?php
/**
* @author alihammad
* @copyright 2008
*/
if(isset($_GET['name']))
{
if($_GET['name']=="ali")
{
echo "This is a response from the server and it is confirmed that you have written 'ali'";
}
else
echo "This is a response from the server and it is confirmed that you have not written 'ali'-->".$_GET['name'];
}
?>