1

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.

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.

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

[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

EDIT

Obviously the failure comes from 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.

Dwza
  • 6,494
  • 6
  • 41
  • 73
  • Do you get any error? – Nishan Senevirathna Oct 07 '14 at 11:05
  • No, not at all. I don't know how to recive error from php when using ajax/jquery. But i guess there would be non because actually he does the post but not to 100% :) – Dwza Oct 07 '14 at 11:07
  • Maybe you hit the limit of input vars. Could you tell us your settings regarding the number of post variables that can be sent? See here what I'm talking about: http://stackoverflow.com/questions/9807100/post-max-array-size – Marvin Saldinger Oct 07 '14 at 11:11
  • I can't give you a exact answer. but.. Did you receive same amount of element in each post? I mean did you receive 31 element all the time? if so probably specific element (i.e 31 st) may contain malformed data. so rearrange items and try again. – Nishan Senevirathna Oct 07 '14 at 11:12
  • @NishanSenevirathna yes its always 31 elements and it doesn't matters what data i take, even its 100 times the same data it stop at 31 and 31 is also never completed. I already tested this – Dwza Oct 07 '14 at 11:14
  • @MarvinSaldinger actually i don't have any input fields :) I'm collecting this from a but like i sayed, that's not the problem. I i print befor using post, i get 40 elemtes or even more as expected. – Dwza Oct 07 '14 at 11:15
  • 1
    @Dwza yeah, but the web server has a limit. It doesnt matter there are no input fields the data is still sent the same way. – Marvin Saldinger Oct 07 '14 at 11:21
  • i checked the size, its 64M guess this should be enough. Shouldn't it ? – Dwza Oct 07 '14 at 11:25
  • @Dwza what about this variable: http://php.net/manual/en/info.configuration.php#ini.max-input-vars – Marvin Saldinger Oct 07 '14 at 11:33
  • @MarvinSaldinger no, that's not it :) I could enclose the failure a lil bit, see my edit in my post. – Dwza Oct 07 '14 at 11:44
  • could you please provide us the data being sent to the server, by inspecting the request in ***network/console*** tab in developer tools? I agree with @MarvinSaldinger, that your are exceeding the post var limit. – code-jaff Oct 07 '14 at 11:51
  • obviously i do exeed the limit. I am trying to change it but its not as easy as it sounds :) If I tested it, I will accept the answere of @MarvinSaldinger :) – Dwza Oct 07 '14 at 12:24

3 Answers3

3

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

31 x 32 = 992

992 + 7 = 999

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

Try increasing max_input_vars to 2000 and see if anything changes.

Marvin Saldinger
  • 1,290
  • 1
  • 16
  • 34
  • this looks good and sounds plausible but adding informations to .htaccess results a internal server error :) but this COULD be the problem :) – Dwza Oct 07 '14 at 12:07
  • omg, you saved my life... or something like this :) at least a lot of gray cells are saved ^^ added new limit to my php.ini on my server and it really solved it. Thought my code is so bad and wasted at least 24h active codingtime + 20 min for writing this post :) Thx alot. – Dwza Oct 07 '14 at 12:48
0

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

$.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.

  • I am passing it as object filled with arrays. One array is called artikel. But for debugging i only pass it as raw array. Has the same result. – Dwza Oct 07 '14 at 11:20
0

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

Romeo
  • 521
  • 5
  • 20