Five-step use of XMLHttpRequest object in Ajax Summary

Source: Internet
Author: User

Five steps to use the XMLHTTPRequest object:

1. Create an XMLHTTPRequest object

2. register the callback function

3. set parameters for interaction with the server (open method)

4. send data to the server and start interaction (send method)

5. Check whether the interaction ends and whether the response data is received successfully in the callback function.

Next, we will explain the problems that may occur in each step and the precautions:

First, because of the browser version and XMLHttpRequest support, there are some differences when creating xmlhttpreque objects.

In the IE family, versions earlier than IE7 regard XMLHttpRequest as an ActiveX control. To create an XMLHTTPRequest object, use the following statement:

XMLHTTP = newactivexobject (name)

The names here are also different, because the names of the controls they define are different for different ie versions. Microsoft. XMLHTTP is the most commonly used one.

Of course, there are some "amazing": "msxml2.xmlhttp. 6.0 "," msxml2.xmlhttp. 5.0 "," msxml2.xmlhttp. 4.0 "," msxml2.xmlhttp. 3.0 "," msxml2.xmlhttp ", these are only for some very old versions of browsers.

When registering a callback function, you must note that registration is not a call. What we need is the method name of the callback function, rather than the return value of the callback function.

The open method is used to set parameters for server interaction. This includes method name, server address, and Asynchronous Method.

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.