Ajax.
HTML code

<! PUBLIC DOCTYPE HTML "-///DTD/W3C 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> Compatible with more browsers AJAX portal instance (more detailed comments) </title>
<The script type="text/javascript" >
<! -
//Ajax is established under the XMLHttp component technology, this example syntax in detail refer to the manual compression bags XMLHttp
var XMLHttp
//build the XMLHttp object call MS ActiveXObject method, if successful (Internet explorer) is using the MS ActiveX instantiation creates an XMLHttp object of IE is to establish a native Javascript objects the XMLHttp object (this method ensure under different browser support for Ajax)
function createXMLHttp () {
if (window. The XMLHttpRequest) {//Mozilla browser
XMLHttp=new XMLHttpRequest ();
} else if (window. The ActiveXObject) {//IE browser
try {
xmlHttp=new ActiveXObject (" Msxml2. XmlHttp ");
} the catch (e) {
try {
xmlHttp=new ActiveXObject (" Microsoft. XmlHttp ");
} the catch (e) {}

}}
}

//build the main process function startXMLHttp () {
createXMLHttp ();//build the xmlHttp object
var send_string="name=" + document. GetElementById (" name "). The value;
send_string=encodeURI (send_string)
//alert (document. GetElementById (" text "). The value);
//return;
xmlHttp. OnreadyStatechange=tonight.but I;//under the xmlHttp onreadystatechange method of control transfer process.
xmlHttp open (" post ", "ajax_show. PHP", true);//mode of pages to be read asynchronous or not.
//xmlHttp setRequestHeader (" cache-control ", "no - cache");
xmlHttp. SetRequestHeader (" content-type ", "application/x - WWW - form - urlencoded");
xmlHttp. Send (send_string);//send the

} function tonight.but I () {
if (xmlHttp. ReadyState==4) {//readyState under the xmlHttp method 4 said transferred
if (xmlHttp. Status==200) {//status of xmlHttp method reads the state corresponding OK HTTP status code (server) 200 404 corresponds to the Not Found (Not Found), etc.
document. The getElementById (" content "). The innerHTML=xmlHttp. The responseText//the responseText xmlHttp method gets read page data
}
}
}
- >
</script>
</head>
<Body>
<Span id="content" >To replace the content </span> <Br>
<Input type="button" value="http://www.script-home.com//article/AJAX for"/>
<The form id="form1" name="form1" method="post" action="" >
<Label>
<Input type="text" name="name" id="name"/>
</label>
</form>
</body>
</html>

ajax_show. PHP program code


<? The PHP $content
=isset ($_POST [' name '])? $_POST [' name '] : "';
echo $content;
? >


This concludes the body part