Understanding XMLHttpRequest Objects

Source: Internet
Author: User

We all know that Ajax refers to a small amount of data interaction with the server without the need for a refresh, which allows the page content to be updated without refreshing. The core object of Ajax is XMLHttpRequest , XMLHttpRequest objects are well supported in all modern browsers and can be used directly. You need to use a specific constructor , ActiveXObject (), to create the IE7 previous browser.

Using the XMLHttpRequest object only needs to build an instance, as follows:

var New XMLHttpRequest ();

The object instance that we created is something that can be printed out to look at.

The first step in using the XHR object is to use the open () method, which has three parameters, the first parameter is the type that needs to send the request (Post/get), the second parameter is the requested server address, and the third parameter refers to whether the request is asynchronous or synchronous, as follows:

Xhr.open ("Get", "01.php",false);

The above code initiates a get-way asynchronous request to a 01.php file, but this step does not actually send the request, just means that the request is ready, the sending request needs another method send () , the Send () method receives a parameter, This parameter is the data that needs to be sent, and if you do not need to send the data, null is passed in

Understanding XMLHttpRequest Objects

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.