Hi There!
I have a Ajax Function copied from W3Shools
I have modified them as my Requirement but it won able to send the xmlHTTP request to my PHP page for result
here the function
function showUser(str,txtId,mth,url)
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
document.getElementById(txtId).innerHTML=xmlhttp.responseText;
}
url = url+"?str=";
xmlhttp.open(mth,url+str,true);
xmlhttp.send();
}
The HTML Page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax</title>
<script type="text/javascript" src="ajax.js"></script>
</head>
<body>
<form method="GET" action="" name="myForm" id="myForm" onkeyup="showUser('this.value','txtHint','GET','d.php');">
<input type="text" name="txtStr" id="txtStr">
<span id="txtHint" name="txtHint"></span>
</form>
</body>
</html>
and the PHP page
<?php
$str = $_GET['str'];
echo $str;
echo "Hello";
?>
Is there anyone can help me please !
Thanks in Advanced