The AJAX request contains arrays.

Source: Internet
Author: User

The AJAX request contains arrays.

We should all find that when the data we send the AJAX request carries an array, it cannot be directly sent to the background like the normal JSON data.

For example, the following data needs to be sent to the backend:

{  "orderId": 22,  "resourceJson": [    {      "carCapacity": 223,      "carNumber": "123",      "driverInfo": "123",      "failReason": "3123123",      "id": 25,      "ispass": 0,      "lineId": 784,      "load_plan": "123",      "onPackageDay": 123,      "price": 123,      "storeOutCapacity": 123,      "store_out_capacity": 123    },    {      "failReason": "31231231",      "id": 2,      "ispass": 0,      "lineId": 787,      "load_plan": "123",      "store_out_capacity": 123,      "tallyman": "ddd"    },    {      "failReason": "123123",      "id": 1,      "ispass": 0,      "lineId": 785,      "load_plan": "123",      "store_out_capacity": 123,      "tallyman": "fff"    }  ]}

The resourceJson field is an array. If the JSON data is directly transmitted to the background

The data obtained in the background looks like this:

The browser automatically parses the array into variables, and the data obtained in the background is directly dumb.

Therefore, the best way is to program the array string. It is very simple to store the array separately with a variable, and thenJSON.stringify(Array), put the obtained string into the JSON data, so that the browser will not automatically help you deconstruct the array, the background is a real array.

Summary

The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.

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.