XMLHttpRequest POST数据大小 [英] XMLHttpRequest POST data size

查看:684
本文介绍了XMLHttpRequest POST数据大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XHR POST请求是否有大小限制?我正在使用POST方法使用PHP脚本将文本数据保存到MySQL中,并且数据已被切断. Firebug向我发送以下消息:

Is there a size limit to a XHR POST request? I am using the POST method for saving textdata into MySQL using PHP script and the data is cut off. Firebug sends me the following message:

... Firebug request size limit has been reached by Firebug. ... 

这是我发送数据的代码:

This is my code for sending the data:

function makeXHR(recordData)
{
    xmlhttp = createXHR();

    var body = "q=" + encodeURIComponent(recordData);

    xmlhttp.open("POST", "insertRowData.php", true);
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", body.length);
    xmlhttp.setRequestHeader("Connection", "close");

    xmlhttp.onreadystatechange = function() 
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
        {
            //alert(xmlhttp.responseText);
            alert("Records were saved successfully!");
        }
    }
    xmlhttp.send(body);

}

我能想到的唯一解决方案是拆分数据并使XHR请求排队,但我不喜欢它.还有另一种方法吗?

The only solution I can think of is splitting the data and making a queue of XHR requests but I don't like it. Is there another way?

推荐答案

XHR Post没有大小限制,但是您正在将数据发送到具有大小限制的PHP;) 创建以下php文件并在浏览器中将其打开:

XHR Post has no size limit, but you're sending data to PHP which has a size limit ;) Create the following php-file and open it in a browser:

<?php phinfo(); ?>

现在搜索变量"post_max_size",此变量限制了可以发送到PHP的最大数据(但是可以在php.ini中更改)

Now search for the variable "post_max_size", this variable limits the maximum data that can be sent to PHP (but it can be changed in the php.ini)

这篇关于XMLHttpRequest POST数据大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆