XMLHTTP objects and their methods

Source: Internet
Author: User
Tags object contains return string client
xml| objects

The Microsoft.XMLHTTP object is provided in MSXML to perform the conversion from the packet to the request object and to send the task.
The statement that creates the XMLHTTP object is as follows:
Set Objxml = CreateObject ("Msxml2.xmlhttp") or
Set Objxml = CreateObject ("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set XML = Server.CreateObject (' MSXML2. ServerXMLHTTP ")
Invoke the Open method to initialize the request object after the object is created, in the form of the following syntax:
Poster.open http-method, url, async, UserID, password
The Open method contains 5 parameters, the first three are necessary, and the last two are optional (provided when the server requires authentication). The meaning of the parameter is as follows:
Http-method:http means of communication, such as Get or POST
URL: The URL address of the server that receives the XML data. The ASP or CGI program is usually indicated in the URL
Async: A Boolean identifier that indicates whether the request is asynchronous. In the case of asynchronous communication (true), the client does not wait for a response from the server; if it is synchronous (false), the client waits for the server to return to the message before performing another operation
UserID user ID, for server authentication
Password user password for server authentication
Send method of XMLHTTP object
After you initialize the request object with the Open method, call the Send method to send the XML data:
Poster.send Xml-data
The parameter type of the Send method is a variant, which can be a string, a DOM tree, or any stream of data. The way to send data is divided into two types: synchronous and asynchronous. In asynchronous mode, once the packet is sent, the send process is terminated, the client performs other actions, and in synchronous mode, the client waits until the server returns a confirmation message before the send process ends.
The readystate attribute in the XMLHTTP object can reflect the server's progress in processing the request. The client's program can set the corresponding event-handling method based on this state information. The property 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 yet ended
1 XML document already loaded
2 XML document already loaded, in process
3 Part XML document has been parsed
4 The document has been parsed and the client can accept the return message
Client Processing Response Information
The client receives the return message, carries on the simple processing, basically completes an interaction period between C/S. The client receives the response through the properties of the XMLHTTP object:
Responsetxt: Returns the message as a text string;
Responsexml: The return message is treated as an XML document and is used when the server response message contains XML data;
Responsestream: Treats the return message as a stream object.

If you want to cross browser such as Firefox:


He will return different XMLHTTP according to different browsers.
See more specifically:
Http://jibbering.com/2002/4/httprequest.html



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.