Core JS Code of asynchronous request
Function callserver (type, URL, isasync, user, password ){
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
// The open method contains five parameters. The first three parameters are required, and the last two parameters are optional (provided when the server requires authentication)
// The data transmission method is get or post, the URL of the Service webpage, and whether the request is asynchronous (true by default, that is, asynchronous execution. False, synchronous execution), user name (can be omitted), user password (can be omitted)
XMLHTTP. Open (type, URL, isasync, user, password );
// If the open method is defined as post, you can define form-based upload.
If (type. touppercase = "Post "){
XMLHTTP. setRequestHeader ("Content-Type", "application/X-WWW-form-urlencoded ");
// XMLHTTP. Send (strparamstring );
}
If (isasync) {// Asynchronous Method
XMLHTTP. onreadystatechange = update;
XMLHTTP. Send ();
}
Else {// Synchronization Method
XMLHTTP. Send ();
If (XMLHTTP. Status = 200 ){
// Responsetext: uses the returned message as a text string;
// Responsebody: uses the returned message as the HTML document content;
// Responsexml: regards the returned message as an XML document, which is used when the server response message contains XML data;
// Responsestream: treats the returned message as a stream object.
VaR ret = XMLHTTP. responsetext; // This is the data returned from the synchronous request.
}
}
}
// Asynchronous callback function
Function Update (){
If (XMLHTTP. readystate = 4 ){
VaR response = XMLHTTP. responsetext; // This is the data returned from the asynchronous request.
}
}
Core background code (create An ASPX page for processing requests ):
Protected void page_load (Object sender, eventargs E)
{
String ret = "this is Microsoft. XMLHTTP"; // here is the data you want to organize.
Response. Write (RET );
Response. End ();
}
Front-End call code:
VaR url = "webserver. aspx"; // you can attach parameters and obtain the parameters in the background.
Callserver ("Post", URL, true ,"","");