apache jquery ajax POST 大小限制?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1548258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:15:19  来源:igfitidea点击:

jquery ajax POST size limit?

phpajaxapachecodeigniterpost

提问by twh

I'm using jquery to send text back to my ajax.php controller like this:

我正在使用 jquery 将文本发送回我的 ajax.php 控制器,如下所示:

var dataString = "1234567890";      
$.post(
    '../ajax/save',
    { data: dataString },
    function(){
        alert("success");
    },
    "text");

It works well, that is until the dataString gets to be ~3500 characters long. At that upper limit (~3.5 KB), the $_POST received by ajax.php is NULL. Why?

它运行良好,直到 dataString 长度达到 ~3500 个字符为止。在该上限(~3.5 KB)下,ajax.php 收到的 $_POST 为 NULL。为什么?

(My php.ini post_max_size = 64M, so it's not that.)

(我的 php.ini post_max_size = 64M,所以不是那个。)

My setup: Apache 2.2, PHP 5.2.9, and CodeIgniter 1.7.1.

我的设置:Apache 2.2、PHP 5.2.9 和 CodeIgniter 1.7.1。

采纳答案by twh

I figured it out. For some reason NetBeans' debugger tells me $_POST['data'] is null, but it's not. To manually determine the size of the $_POSTreceived, I used these calls:

我想到了。出于某种原因,NetBeans 的调试器告诉我 $_POST['data'] 为空,但事实并非如此。为了手动确定$_POST接收的大小,我使用了以下调用:

$request = http_build_query($_POST);
$size = strlen($request);

Also, I was putting $_POST['data'] into CodeIgniter's session:

另外,我将 $_POST['data'] 放入 CodeIgniter 的会话中:

$event_array = array('event' => $_POST['data']);
$this->session->set_userdata($event_array);

Which was coming up empty leading me to further believe that $_POST was empty. But the problem was instead $this->session, which apparently has a 4K size limit (according to this post).

这是空的,导致我进一步相信 $_POST 是空的。但问题是$this->session,它显然有 4K 大小限制(根据这篇文章)。