Solution to the truncation of the array when submitting a post request in php ajax
1. Scene
When I saved the special product list today, I found that there were more than 2,300 pieces of data on the front end, but the actual server only accepted 166 pieces of data and stored them in the database
2. Solution process
After debugging, it was found that the amount of data was correct when the front-end page submitted the post request, but only 166 items could be received from the server.
At first I thought the post request length exceeded the limit, but after looking at the request content, it was only over 200K, and the post request default supports data transmission within 8M.
So I suspected that it might be caused by the internal configuration of PHP. Later, Baidu searched and found the configuration item max_input_vars. This configuration item was added after PHP 5.3.9 version to prevent hash conflicts.
In this case, change the configuration item, The default is 1000, change it to 10000; after restarting the service, it is found that the amount of data obtained by the server is 1666, which is 10 times the previous one, which is exactly what happened after the configuration item was adjusted. multiple.
However, the amount of data transmitted by the front end is uncertain. Even if max_input_vars is set to 100,000, it may not be enough, so we should find another way.
3. Final solution
1. The front end converts the array into json for transmission, that is, JSON.stringify(goodsList)
2. The server receives and parses $goodsList = json_decode($_POST['goodsList'], true);
3. The test found that the data sent from the front end can be obtained by the server, and the problem was successfully solved

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics









