Understanding of XMLHTTP objects-basic knowledge

Source: Internet
Author: User

1 XMLHTTP is a set of APIs that transmit or receive XML and other data through the HTTP protocol in JavaScript scripting languages.

(XMLHTTP is a set of APIs that transmit and receive data through the HTTP protocol.) )

2 XMLHTTP provides a protocol for client communication with the HTTP server, which sends a request to the HTTP server via the XMLHTTP object (msxml2.xmlhttp.3.0) and uses the DOM to process the response.

2.1 XMLHTTP objects are created in a way that distinguishes IE and non-IE browsers:

Example: Create a XMLHTTP object and request an XML document from the server, which is displayed after the document is returned. The following are examples of IE and non-IE explained

1 IE Browser uses ActiveXObject method to create XMLHTTP objects:

var xmlhttpreq = new ActiveXObject ("msxml2.xmlhttp.3.0");

Xmlhttpreq.open ("Get", "Http://localhost/test.xml", false);

Xmlhttpreq.send ();

alert (Xmlhttpreq.responsetext);

2 non-IE browsers use the XMLHttpRequest method to create XMLHTTP objects:

var xmlhttpreq = new XMLHttpRequest ();

Xmlhttpreq.open ("Get", "Http://localhost/test.xml", false);

Xmlhttpreq.send ();

alert (Xmlhttpreq.responsetext);

2.2 after the XMLHttp object is created, because it is a set of APIs, it has a number of methods and properties, such as the Open (), send (), and responsetext used above.

The XMLHTTP object's code is handled in a more fixed way. So the next thing to do is to follow the example in order to understand it.

The biggest benefit of the 3 XMLHTTP is that updating parts of the page does not require refreshing the entire page.

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.