Add Xmlhttp.setrequestheader ("If-modified-since", "0") before Ajax sends the request;
In the URL home a random number of what, I used the next, not very good.
The specific code is as follows:
Here's the code:
<title>my-A-Ajax programe</title>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script language= "javascript" type= "Text/javascript" >
<!--
var XmlHTTP;
// =======================================
Function Name:creatxmlhttp ()
Function:creat XMLHttpRequest Object
// =======================================
function Createxmlhttp () {
if (window. ActiveXObject) {
XmlHTTP = new ActiveXObject (' microsoft.xmlhttp '); If IE
}
else if (window. XMLHttpRequest) {
XmlHTTP = new XMLHttpRequest ();
}
}
function Gethtmlinfo (URL) {
Createxmlhttp ();
Xmlhttp.open ("Get", URL, True);
Xmlhttp.onreadystatechange = callhtml;
Xmlhttp.setrequestheader ("If-modified-since", "0");
Xmlhttp.send ();
}
function callhtml () {
if (xmlhttp.readystate = = 4) {
if (Xmlhttp.status ==200) {
Alert ("Server return information:" + xmlhttp.responsetext);
document.write (Xmlhttp.responsetext); Will load html.htm to the current page
}
}
}
-->
</script>
<body>
<form name= "Frmtest" action= "#" >
<input name= "Btnshowinfo" type= "button" value= "Display server return information" >
</form>
</body>
|