Get and POST attributes of the XMLHttpRequest object

Source: Internet
Author: User
You may want to know the differences between GET and POST and when to use them. Theoretically, if a request is idempotent, you can use GET. idempotence means that multiple requests return the same result. you may want to know the difference between GET and POST, and want to know when to use them . Theoretically, if the request is idempotent, it can be used. GET The power equality means that multiple requests return the same result. In fact, the corresponding server method may modify the status in some way, so this is generally not true. This is just a standard.The actual difference is the size of the net load. in many cases, the browser and server limit the URL length to send data to the server. Generally, GET can be used to obtain data from the server. In other words, you must avoid using GET to change the status on the server.

Generally, the POST method should be used when the status on the server is changed. Unlike GET, you need to set the Content-Type header of the XML-HttpRequest object, as shown below:

XmlHttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ");

Unlike GET, POST does not limit the size of the net load sent to the server, and the POST request cannot be idempotent.

Most of the requests you make may be GET requests. However, you can use POST if necessary.

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.