php - $_POST 请求期间数据中断

标签 php jquery ajax post

我无法弄清楚以下 $_POST 请求的问题所在。问题是我通过 AJAX $_POSTing 一个包含 855 条记录的数组,但我的 AJAX Controller 只接收 833。它总是接收到相同的记录,并且它总是在同一点切断:

查询:

var f = {};
f.chargeID = chargeID;
f.method = 'saveIndividualApplications';
f.individualAmounts = individualAmts;

processing.show();

console.log(f); //all records present
console.log(Object.keys(f.individualAmounts).length); //855

return $.ajax({
    type: 'post',
    cache: false,
    url: appControllerPath,
    data: f
});

PHP Controller :
$displayMaxSize = ini_get('post_max_size'); //125912
file_put_contents('post', $_SERVER['CONTENT_LENGTH'] . "\r\n"); //240M (increased this to 240 just to check)
file_put_contents('post', $displayMaxSize . "\r\n", FILE_APPEND);
file_put_contents('post', print_r($_SERVER, true), FILE_APPEND);
file_put_contents('post', count($_POST['individualAmounts']) . "\r\n", FILE_APPEND); //833
file_put_contents('post', print_r($_POST['individualAmounts'], true), FILE_APPEND); // data cuts off midway through 833rd record (although the array seems to close fine)

最佳答案

可以通过 max_input_vars 配置选项进行限制,默认限制为 1000。在 5.3.9 中引入,检查 PHP runtime config

或者,如果您使用的是 Suhosin,则可能会受到它的限制

[suhosin]
suhosin.request.max_vars = 1000
suhosin.post.max_vars = 1000

关于php - $_POST 请求期间数据中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31878374/

相关文章:

javascript - 在原型(prototype)内部运行 JS/JQuery

java - 使用 jQuery/Ajax 将多个选定的复选框发送到 Java

PHP、Javascript JSON、XSS 保护

php - 数据表在 codeigniter 中不起作用

javascript - Codeigniter 中的 jQuery 自动完成

javascript - hasClass 不起作用

php - DISTINCT 函数不能与 $wpdb 一起在线工作

javascript - 单击 "continue"按钮 Javascript 时单选按钮验证

java - 手动执行 CORS

javascript - 如果输入为空,则禁用提交按钮