Ajax data request to pass an array object type value unsuccessful understanding!

Source: Internet
Author: User

encountered this problem also looked for a lot of network resources, the Internet is mostly said that the array has two ways: one is splicing string, the second is the request is the use of traditional mode traditional:true;

Citation ( 76165971 ) ( 53836906/ )

Most of the answers are in the second way, but this approach is not resolved for my request.

finally through 415 error found contentType:application/x-www-form-urlencoded not allowed;

Finally, find out the following information:

ContentType mainly sets the format you send to the server,dataType Sets the format you receive the server data.

# #而contentType default format is application/x-www-form-urlencoded;

This format is characterized by, Name/value Become a group, between each group with & join, and name value = connection. This pass can only be a simple key-value pair format pass, which is a simple json format; But in complex cases, a complex json format array nested objects, objects containing arrays or objects nested arrays, arrays containing objects, etc., application/ X-www-form-urlencoded There is no way to organize complex JSON into key-value pairs. {A: 1, B: 2, C: 3}

# #contentType : Application/json ; This type is text , we Ajax the complex JSON Data with json.stringify after serialization, it is then sent, on the server side and then with the Json.parse It's OK to restore, so you can handle complex objects.

{data: {a: [{x: 2}]}}

Ajax data request to pass an array object type value unsuccessful understanding!

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.