通过jQuerys $传递数组。职位减少头寸

时间:2021-06-19 21:30:26

I can't find any suitable answeres so I ask a new question.

我找不到合适的答案,所以我问了一个新问题。

I am working on a bigger webapplication. Now in one Part of the app I collect data from an existing table (<table class="myContent">...</table>) with jQuery. Code doesn't matters at this point.

我正在开发一个更大的网络应用程序。现在,在应用程序的一部分中,我使用jQuery从现有表(

)收集数据。代码在这一点上并不重要。

What happens is, I create a Array with content in it and it works fine. Content looks like

发生的是,我创建了一个包含内容的数组,它运行良好。内容看起来像

Array
(
[artikel] => Array
    (
        [0] => Array
            (
                [id] => 602145-69430
                [name] => Legraphic 2 Top
                [farbe] => Cashmere Blue mix
                [menge] => 0
                [epreis] => 25.95
                [gpreis] => 0.00
                [uvp] => 64.90
                [grt1] => XS
                [grt2] => S
                [grt3] => M
                [grt4] => L
                [grt5] => XL
                [grt6] => XXL
                [grt7] => 0
                [grt8] => 0
                [grt9] => 0
                [grt10] => 0
                [grt11] => 0
                [grt12] => 0
                [gr1] => 
                [gr2] => 
                [gr3] => 
                [gr4] => 
                [gr5] => 
                [gr6] => 
                [gr7] => 
                [gr8] => 
                [gr9] => 
                [gr10] => 
                [gr11] => 
                [gr12] => 
                [ldate] => LD: 01.02.2015 - 28.02.2015
            )

        [1] => Array
            (
                [id] => 602145-60430
                [name] => Legraphic 2 Top
                [farbe] => Cashmere Blue
                [menge] => 0
                [epreis] => 25.95
                [gpreis] => 0.00
                [uvp] => 64.90
                [grt1] => XS
                [grt2] => S
                [grt3] => M
                [grt4] => L
                [grt5] => XL
                [grt6] => XXL
                [grt7] => 0
                [grt8] => 0
                [grt9] => 0
                [grt10] => 0
                [grt11] => 0
                [grt12] => 0
                [gr1] => 
                [gr2] => 
                [gr3] => 
                [gr4] => 
                [gr5] => 
                [gr6] => 
                [gr7] => 
                [gr8] => 
                [gr9] => 
                [gr10] => 
                [gr11] => 
                [gr12] => 
                [ldate] => LD: 01.02.2015 - 28.02.2015
            )

and so on. Now after creating this array, I send it like

等等。创建这个数组后,我像这样发送它

$.post('php/_includes/_ajaxIncludes/ajax.inc.container.php', 
        {
            section:    'save',
            data:       myArray

        });

I call ajax.inc.container.php and in that file I include a file named save.php. I can switch the inc-file by changing the section-parameter.

我叫ajax.inc.container。在这个文件中,我包含一个名为save.php的文件。我可以通过更改sec-参数来切换这个文件。

Now here is the issue:

现在的问题是:

The created array has eg. 40 positions (or even more) in artikel (I did console.log(myArray); right before $.post) but if I print_r($_POST['data']['artikel']); in php, I only get 31 positions and the last position isn't even completed. Looks like

创建的数组具有eg。在artikel中有40个位置(甚至更多)(我做了console.log(myArray);但是如果我打印_r($_POST['data']['artikel']]);在php中,我只有31个位置,最后一个位置甚至没有完成。看起来像

[31] => Array
            (
                [id] => 602147-69430
                [name] => Leblock 1 Blouse
                [farbe] => Cashmere Blue mix
                [menge] => 0
                [epreis] => 35.95
                [gpreis] => 0.00
                [uvp] => 89.90
            )

anyone know why this can happen ?

有人知道为什么会发生这种事吗?

Additional informations:

额外的信息:

post_max_size 64M

post_max_size 64

EDIT

编辑

Obviously the failure comes from jquery.

显然,失败来自jquery。

If I add .done() and .fail() to $.post() and return the response console.log(response); he goes into fail() if there are more than 30 positions.

如果我将.done()和.fail()添加到$.post()并返回response console.log(response);如果有超过30个职位,他就会失败。

3 个解决方案

#1


3  

So you receive only 31 complete array elements and the 32nd element has only 7 items. Each element has 32 items.

所以你只收到31个完整的数组元素,而第32个元素只有7个元素。每个元素有32个条目。

31 x 32 = 992

31 x 32 = 992。

992 + 7 = 999

992 + 7 = 999

The default for max_input_vars is 1000. Maybe I missed one...

max_input_vars的默认值是1000。也许我错过了一个…

Try increasing max_input_vars to 2000 and see if anything changes.

尝试将max_input_vars增加到2000,看看是否有什么变化。

#2


0  

You post data as a raw array. Instead of try to parse JSON object as a string. for eg:

将数据作为原始数组发布。而不是尝试将JSON对象解析为字符串。如:

$.post('php/_includes/_ajaxIncludes/ajax.inc.container.php', 
    {
        section:    'save',
        data:       JSON.stringify(myArray)

    });

Then parse this string to json object. I know this is not the answer for your question but this may help you.

然后将这个字符串解析为json对象。我知道这不是你的问题的答案,但这可能会对你有所帮助。

#3


0  

If you create the Array in PHP use serialize() and pass it as a string. Then deserialize() it.

如果在PHP中创建数组,请使用serialize()并将其作为字符串传递。然后反序列化()。

#1


3  

So you receive only 31 complete array elements and the 32nd element has only 7 items. Each element has 32 items.

所以你只收到31个完整的数组元素,而第32个元素只有7个元素。每个元素有32个条目。

31 x 32 = 992

31 x 32 = 992。

992 + 7 = 999

992 + 7 = 999

The default for max_input_vars is 1000. Maybe I missed one...

max_input_vars的默认值是1000。也许我错过了一个…

Try increasing max_input_vars to 2000 and see if anything changes.

尝试将max_input_vars增加到2000,看看是否有什么变化。

#2


0  

You post data as a raw array. Instead of try to parse JSON object as a string. for eg:

将数据作为原始数组发布。而不是尝试将JSON对象解析为字符串。如:

$.post('php/_includes/_ajaxIncludes/ajax.inc.container.php', 
    {
        section:    'save',
        data:       JSON.stringify(myArray)

    });

Then parse this string to json object. I know this is not the answer for your question but this may help you.

然后将这个字符串解析为json对象。我知道这不是你的问题的答案,但这可能会对你有所帮助。

#3


0  

If you create the Array in PHP use serialize() and pass it as a string. Then deserialize() it.

如果在PHP中创建数组,请使用serialize()并将其作为字符串传递。然后反序列化()。