Workaround for PHP Ajax to submit post requests for array truncation

Source: Internet
Author: User

First, the scene

Today to save the list of special items found that there are more than 2,300 front-end data, but the actual server accepted into the database only 166

Ii. process of Settlement

Debugging found that the front-end page submits a POST request with the correct amount of data, but only 166 is accepted to the server.

The first thought was that the post request was longer than the limit, but looked at the request content of more than 200 k, and the POST request by default supports data transfer within 8M.

So suspicion may be caused by the internal configuration of PHP, and then Baidu was sure to find max_input_vars This configuration item, which was added after PHP 5.3.9, to prevent hash collisions .

That being the case, change the configuration item to 10000 by default, and then restart the service to find that the amount of data fetched by the server is 1666, which is 10 times times the previous one, which is exactly the multiple of the configuration item adjusted.

However, the data volume of the front-end transmission is uncertain, even if the max_input_vars set to 100,000, it may not be enough, or another way to find him.

Third, the Final Solution

1. The front end converts the array into JSON transfer, i.e. json.stringify (goodslist)

2, the server received and resolved $goodslist = Json_decode ($_post[' goodslist '), true);

3, the test found that the front end of the data service can be obtained, the problem is resolved satisfactorily

Workaround for PHP Ajax to submit post requests for array truncation

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.