Paste the sample code, which is valid in IE (sogou is ineffective), and others are not tested.
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<SCRIPT type = "text/JavaScript">
Function btnclick (){
VaR XMLHTTP = new activexobject ("Microsoft. XMLHTTP"); // create an XMLHTTP object
If (! XMLHTTP ){
Alert ("An error occurred while creating the XMLHTTP object! ");
}
XMLHTTP. Open ("Post", "getdate. ashx? TS "+ new date (), false );
XMLHTTP. onreadystatechange = function (){
If (XMLHTTP. readystate = 4 ){
If (XMLHTTP. Status = 200 ){
Alert (XMLHTTP. responsetext );
Document. getelementbyid ("text1"). value = XMLHTTP. responsetext;
}
Else {
Alert ("ajax server return error ");
}
}
}
XMLHTTP. Send ();
}
</SCRIPT>
</Head>
<Body>
<Input id = "text1" type = "text"/>
<Input id = "button1" type = "button" value = "button" onclick = "btnclick ()"/>
</Body>
</Html>
The getdate. ashx page only returns the server time, which is useless. The Code is as follows:
Public void processrequest (httpcontext context ){
Context. response. contenttype = "text/plain ";
Context. response. Write (datetime. Now. tostring ());
}
Public bool isreusable {
Get {
Return false;
}
}