Creating a statement for the XMLHTTP object is as follows:
Set Poster = CreateObject ("Microsoft.xmlhttp") method
The OPEN method is called after the object is created, and the REQUEST object is initialized. The syntax format is:
Poster.open http-method, url, async, userid, password
The OPEN method contains 5 parameters, the top three are necessary, the latter two are optional (provided when the server needs to be authenticated). The meaning of the parameters is as shown in the following table:
Parameter Description HTTP-MethodHTTP communication method, such as a URL address of the server that receives XML data. The ASP or CGI program async is usually indicated in the URL, indicating whether the request is asynchronous. If it is an asynchronous communication method, the client will not wait for the server's response; if it is synchronous mode, the client will wait until the server returns the message to perform other action userid user IDs, used for server authentication Password user password, for servers Authentication: The client sent a POST request to the "xxx.asp" page using an asynchronous manner:
Poster.open "POST", "xxx.asp", false send (varbody) Varbody: Instruction Set. Can be XML format data, or a string, stream, or an unsigned integer array. It can also be omitted, and the instruction will be submitted through the URL parameter of the OPEN method. The parameter type of the Send method is Variant, which can be a string, a DOM tree, or any data stream. The way to send data is divided into synchronous and asynchronous. In an asynchronous mode, once the data package is sent, end the Send process, the client performs other operations; and in the synchronization mode, the client will wait until the server returns a confirmation message to end the Send process. SetRequestHeader (BSTRHEADER, BSTRVALUE) BSTRHEADER: HTTP header (HEADER) BSTRVALUE: HTTP header value If the Open method is defined as POST, you can define a form of unilateral upload: XMLHttp.SetRequestHeader ("Content-Type", "Application / X- WWW-form-urlencoded ") Properties XMLHTTP objects can reflect the progress of the server during processing requests. The program of the client can set the corresponding event processing method according to this status information. The attribute value and its meaning are shown in the following table: Value Description 0 Response object has been created, but the XML document upload process has not ended 1 XML document has been loaded 2 XML document has been loaded, and the 3 part XML document has parsed 4 documents already After the analysis is complete, the client can accept the return message client to process the response information client to receive a return message, basically complete a interaction cycle between C / S. The client receiving response is implemented by the attribute of the XMLHTTP object: OnReadyStateChange: The event handle of the return result is obtained in the synchronous execution mode. Can only be called in the DOM. ResponseBody: Results Returns to an unregulated integer array. ResponseStream: Results Returns to Stream stream. ResponseText: The result is returned to a string. Responsexml: The result is returned to XML format data. Step 1, create an XMLHTTP object // requires MSXML 4.0 support 2, open the connection with the server, and define instruction sending mode, service web page (URL), and request permissions. The client opens the connection to the server's service web page via the Open command. Like the ordinary HTTP instruction, you can point to the server's service web page with the "GET" method or "post" method. 3, send the instruction. 4, waiting and receive the processing result returned by the server. 5, release XMLHTTP object