Understanding of xmlHttp objects

Source: Internet
Author: User

1 xmlHttp is an API for transmitting or receiving XML and other data through Http in JavaScript scripting.

(XmlHttp is an API for transmitting and receiving data through Http .)

2 xmlHttp provides the protocol for communication between the client and the http server. The client sends a request to the http server through the xmlHttp object (MSXML2.XMLHTTP. 3.0) and uses DOM to process the response.

2.1 create an xmlHttp object by using IE and non-ie browsers:

Example: Create an xmlHttp object and request an xml document from the server. The returned document is displayed. The following is an example of IE and non-IE respectively.

1) Use ActiveXObject to create an xmlHttp object in IE:

VarXmlHttpReq =New ActiveXObject ("MSXML2.XMLHTTP. 3.0 ");

XmlHttpReq. open ("GET", "http: // localhost/test. xml", false );

XmlHttpReq. send ();

Alert (xmlHttpReq. responseText );

2) create an xmlHttp object using XMLHttpRequest in a non-IE browser:

VarXmlHttpReq =New XMLHttpRequest ();

XmlHttpReq. open ("GET", "http: // localhost/test. xml", false );

XmlHttpReq. send ();

Alert (xmlHttpReq. responseText );

2.2CreatedXMLHttpObject, because it is a setAPITherefore, it has many methods and attributes, such as open (), send (), and responseText used above.

The code processing method for xmlHttp objects is relatively fixed. Therefore, the following is just an example to understand.

3. The biggest advantage of xmlHttp is that you do not need to refresh the whole page when updating part of the page content.

Related Article

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.