The difference between form data and request payload in AJAX requests

Source: Internet
Author: User

In the HTTP request process, GET request: The form parameter is appended to the URL in the form of name=value&name1=value1;

Post request: The form parameter is in the request body and is also in the form of name=value&name1=value1 in the request body.

When a post form requests a commit, the content-type used is application/x-www-form-urlencoded, and the POST request that uses the native AJAX does not specify the request header Requestheader, The default content-type used is text/plain;charset=utf-8.

Content-type default value of form in HTML: content-type:application/x-www-form-urlencoded

If you use an AJAX request and the request payload in the requester header causes the parameter to change, the solution is:

Headers: {' content-type ': ' application/x-www-form-urlencoded '}

Or use AJAX settings:

$.ajaxsetup ({contentType: ' application/x-www-form-urlencoded '});

In this way, the problem can be solved.

The difference between form data and request payload in AJAX requests

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.