douchi8503 2012-04-11 07:38
浏览 11
已采纳

发送多维对象 - >最后一部分丢失

I'm sending a multidimensional object with an ajax post request but some times the last part of the object is lost? Is there some kind of limit to how much data you can send?

--------

update

when counting the childs in data.accounts before the ajax post the number is 221, and when counting the data.accounts in the success handler the number is still 221

The data being sent is at the most 10kb


When I do this right before the object is sent with ajax, all data is represented

var arr = [];
for(var key in obj){
    arr[arr.length] = key+' = '+obj[key];
}

alert(arr.join('
'));

But when doing this on the backend the last part of the data is lost

print_r($data);

data structure (there are over 200 childs in data.accounts but only 198 are recieved)

    Array
    (
        [account_id_] => 0
        [name] => 1
        [type] => 2
        [type_pl] => Drift
        [type_b] => Status
        [type_p] => 
        [type_h] => Tekst
        [type_t] => Sum
        [att_sumfrom] => 4
        [vatcode] => 3
        [accounts] => Array
            (
                [0] => Array
                    (
                        [account_id_] => 1
                        [name] => OMS�TNING
                        [type] => 3
                        [att_sumfrom] => 
                        [vatcode] => 
                    )

                [1] => Array
                    (
                        [account_id_] => 1000
                        [name] => Varesalg
                        [type] => 0
                        [att_sumfrom] => 
                        [vatcode] => S25
                    )

                [2] => Array
                    (
                        [account_id_] => 1200
                        [name] => Udf�rt arbejde
                        [type] => 0
                        [att_sumfrom] => 
                        [vatcode] => S25
                    )
.......

Sending the data

this.send = function(){
    var jqxhr = $.ajax({
            url : this.url,
            data : this.data,
            timeout : this.no_timeout ? 0:this.timeout,
            cache : this.cache,
            dataType : this.dataType,
            type : this.type,
            global : this.global
        })
  • 写回答

2条回答 默认 最新

  • dqajyxqem115006813 2012-04-11 08:02
    关注

    There is a limit to how much data you can send per request, and depending on what method you're using. If you're using POST in PHP as the backend, take a look at PHP.ini memory_limit and post_max_size, where the former is script memory hogging and the latter is how much data can be sent through post requests. Defaults are 128M and 8M respectively.

    If you're sending too much data that the server is not allowed to handle, the data will be cut as per instructions.

    Update

    It is hard to debug without all the relevant code. Are you doing anything else on the backend before printing the array or are you just print_r($_POST['data'])ing? Because if you're not doing anything else, it still sounds like a memory setting on the server.

    Anecdote

    I remember a project where I had about 400 rows of data, each row had 7 columns (lots of text) that I sent through an AJAX object, and ~70 of the last rows was just cut out. After doubling the post_max_size all the data was being sent properly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算