2

Around 100 rows of data are posted using $.post (JQuery) as JSON array. But for some reason not all rows are received.

The data looks more or less like this (contents are basically numbers and small strings):

rows = [["U", "0", "81949", 32 more...], ["U", "0", "81950", 32 more...] ..... ]

The way I'm sending the data is:

$.post(url+"callback=?", { data : rows }, function(){}, "json");

If I echo the number of rows (count($_POST)) received in my local version it shows "100", but at the production server it displays "25" (every time is the same amount).

Checking the request details in firebug, it shows correctly that all 100 has been sent.

I though it could be the PHP "post_max_size" value, but I had it set to "100M", which I think is by far enough.

I'm pretty sure it has to be with the server settings, but I'm out of ideas... Thanks in advance.

UPDATE:

  • The production server has 8GB of Memory, which is using about half of it (it is not a memory issue).
  • There is no timeout (all the process is done in about 3 seconds).
lepe
  • 24,677
  • 9
  • 99
  • 108
  • 1
    there is a limit for JSON, like other data: See here: [enter link description here][1] [1]: http://stackoverflow.com/questions/1262376/is-there-a-limit-on-how-much-json-can-hold – Yoong Kim Apr 10 '12 at 06:23
  • Seen http://www.phpfreaks.com/forums/index.php?topic=260148.0 ? – Bergi Apr 10 '12 at 06:24

3 Answers3

9

There is already an accepted answer, but for those not using suhosin, the problem may be a low "max_input_vars" php setting. Mine was set to 1000 by default, which was not enough.

Todd Kamin
  • 409
  • 5
  • 4
3

Is your production server using suhosin? Suhosin is often a culprit for limiting the request sizes, both GET and POST. They have separate limits for POST and GET sizes (and in fact one affects the other from what I remember, thus both have to be increased).

Take a look at your phpinfo() and see if there's anything about suhosin there.

Suhosin values that may affect you:

  • suhosin.get.max_vars
  • suhosin.post.max_vars
  • suhosin.request.max_vars

(+ their equivalents for value and var length)

Also, if you're uploading files, then this too is limited by suhosin:

  • suhosin.upload.max_uploads (which is, consequently, 25 by default)
kingmaple
  • 4,200
  • 5
  • 32
  • 44
  • You were right! I forgot about that... I normally remove Suhosin as it also caused other problems before. I just forgot to do it in this new server. Thanks a lot! you saved my day! – lepe Apr 10 '12 at 06:57
0

There is a maximum size for query data - see here. The problem could be one of 2. Either part of the data is being received, or PHP is removing data after a certain amount. See here for this setting in PHP.

Community
  • 1
  • 1
Shane
  • 2,007
  • 18
  • 33
  • 1
    Thanks, but as I said before, the "post_max_size" is set to 100MB. I don't think it is using even 1MB. The maximum query data applies for $_GET no for $_POST. – lepe Apr 10 '12 at 06:36
  • @lepe: Look at the link @Bergi posted, you might have `mod_security` or similar blocking the full request. – David-SkyMesh Apr 10 '12 at 06:51