Client code:
Copy codeThe Code is as follows:
<! 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 = gb2312"/>
<Title> untitled document </title>
</Head>
<Script language = "javascript">
Var xmlHttp;
Function createXMLHttpRequest (){
If (window. ActiveXObject ){
XmlHttp = new ActiveXObject ("microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest ){
XmlHttp = new XMLHttpRequest ();
}
}
Function sendRequest (){
CreateXMLHttpRequest ();
Var name = document. getElementById ("name"). value;
Url = "String_check.php? Page = "+ name;
XmlHttp. onreadystatechange = callback;
XmlHttp. open ('get', url, true );
XmlHttp. send (null );
}
Function callback (){
If (xmlHttp. readyState = 4 ){
If (xmlHttp. status = 200 ){
Document. getElementById ("show"). innerHTML = "your input string is:" + xmlHttp. responseText;
}
}
}
</Script>
<Body>
<P> AJAX test; </p>
<P> <br/>
<Input type = "text" id = "name" onkeyup = "sendRequest ();"/>
<Br/>
<Span id = "show"> </span>
</P>
</Body>
</Html>
Server code:
Copy codeThe Code is as follows:
<? Php
Header ('content-type: text/html; charset = GB2312 ');
$ Ename = $ _ GET ["page"];
If ($ ename = ""){
$ Ename = "Enter :";
}
Echo ($ ename );
Exit (0 );
?>