Explore the difference between synchronization and asynchrony in Ajax _ajax correlation

Source: Internet
Author: User

The request way, divides into get and post:get most common HTTP request, the ordinary browsing page is the get. The parameter request for Get mode is directly followed by the URL and begins with a question mark. (JS used Window.location.search to get). Parameters can be encoded using encodeuricomponent, in the form of:
var enparam = encodeuricomponent (param);

URLs support only about 2K of length, that is, 2048 characters; using get for AJAX requests caches the resulting page is not correct, the general method is random parameter value; ajax.send (null).

POST

Submitting data to the server is used.

You need to remove the values from form forms into strings, connect with & symbols (same as get pass parameters), submit data 2GB, use Ajax.setrequestheader (' Content-type ', ' application/ X-www-form-urlencoded '), processing the submitted string, Ajax.send (strings), which represents what needs to be committed in the form, such as a=1&b=2 a string like this.


Synchronous and asynchronous:

In the Ajax.open method, the 3rd parameter is set either synchronously or asynchronously. Prototype, such as JS class library generally default to asynchronous, that is set to true. First of all, in the case of synchronization, JS will wait for the request to return to get status. The onReadyStateChange event handler function is not required. Asynchronous, however, requires onreadystatechange event handling and a value of 4 to properly handle the content below.

(Note: The Ajax in this article represents the XMLHTTP request object.) )

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.