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.