dongweng6241 2015-06-24 19:46
浏览 41
已采纳

PHP页面只能看到POST数组值中的71项

I have quite an interesting issue. As you can see in the code below, I send 2 POST variables to my PHP page. One of the variables is a JSON array. If unsyncedContacts.length is < 71, it works as intended. As soon as we get over 71 items in the array, the PHP page will only recognize the first 71. I've watched the timeline in chrome as this is happening and the data is under a MB.

Any advice or help would be greatly appreciated as I am at a loss. There are no errors being thrown, and the 71 records that do manage to be sent between the pages are executed properly.

JS

$.ajax({
  url: 'ajax/upsert_contacts.php',
  type: 'POST',
  dataType: 'json',
  data: {
    "contacts": unsyncedContacts,//JSON array
    "userInfo": localStorage.userInfo
  }
})
.done(function(data) {
 //do stuff here. i don't think its part of my issue
});

PHP - upsert_contacts.php

set_time_limit(0);//set the time limit for each contact to prevent breaking.

//POST DATA
$currentUsersName = json_decode($_POST['userInfo']['usersName']);
$contacts         = $_POST['contacts'];
$aCount           = count($contacts);//returns 71 at MOST

I've tried stepping through the PHP with xdebugger and $aCount always returned 71 at most. As I said before, if it were say 50 items in $contacts, it'd work great. Once it hits 72, it gets weird

Edit: Someone asked in the comments, but deleted it: "Whats your server's max_input_vars set to?".

max_input_vars 1000

  • 写回答

1条回答 默认 最新

  • dongxiang3205 2015-06-25 15:06
    关注

    Turns out it was the max_input_vars.

    I had xdebug enabled in my dev environment and for some reason it did not show the PHP warning stating that I had exceeded the 1000 (the array i was passing was a JSON object with 14 properties).

    14*71 = 994, meaning the next array item would go over the 1000 limit that I had set. To remedy this I created a .htaccess file with php_value max_input_vars 20000 to ensure my code wont break again

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?