<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title> New Document </title>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content=www.111cn.net>
<meta name= "keywords" content= "" >
<meta name= "description" content= "" >
<body>
<script language= "Web Effects" type= "Text/javascript" >
<!--
Create a browser-compatible XMLHttpRequest object
var xmlhttp;
try{
xmlhttp= new ActiveXObject (' msxml2.xmlhttp ');
}catch (e) {
try{
xmlhttp= new ActiveXObject (' microsoft.xmlhttp ');
}catch (e) {
try{
xmlhttp= new XMLHttpRequest ();
}catch (e) {}
}
}
To define an event handler for a XMLHttpRequest object
Xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4) {
if (xmlhttp.status==200) {
alert (Xmlhttp.responsetext);
}else{
alert (xmlhttp.status);
}
}
}
Create a connection
Xmlhttp.open ("Get", "a.html");
Send Request
Xmlhttp.send (NULL);
-->
</script>
</body>
A.html
<title> New Document </title>
<body>
Hello,ajax!www.111cn.net
</body>
Returns a detailed instance of Responsexml.
<script language= "javascript" type= "Text/javascript" >
<!--
Building a XMLHttpRequest object across browsers
var xmlhttp;
try{
xmlhttp= new ActiveXObject (' msxml2.xmlhttp ');
}catch (e) {
try{
xmlhttp= new ActiveXObject (' microsoft.xmlhttp ');
}catch (e) {
try{
xmlhttp= new XMLHttpRequest ();
}catch (e) {}
}
}
Create a request to an XML file
Xmlhttp.open ("Get", "a.xml");
Xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4) {
if (xmlhttp.status==200) {
Get XML Object
var xmlobj=xmlhttp.responsexml;
Get the value of <title> node
var title=xmlobj.getelementsbytagname ("title") [0].text;
Alert (title);
}else{
alert (xmlhttp.status);
}
}
}
Xmlhttp.send (NULL);
-->
</script>
A.xml