mrforexify mrforexify - 2 months ago 7
Ajax Question

Jquery ajax is cutting the arrays?

I'm sending two arrays of data to laravel controller. Before sending the length of arrays is about 220 each. Then for test I'm returning response in json back to jquery again with length of arrays and the first one is ok - 220 and the second array is ~114 length.

enter image description here

How can I solve it?

Jquery ajax:

console.log('Array first before '+arr.length);
console.log('Array second before '+arr_planned.length);

$.ajax({
method:'POST',
url:url,
data: {
_token:token,
arr:arr,
arr_planned:arr_planned
}
}).done(function(msg) {
console.log(msg);
});


Controller

$array_normal = $request['arr'];
$array_planned = $request['arr_planned'];

return response()->json(['Array first after' => sizeof($array_normal),'Array second after' => sizeof($array_planned)],200);


Edit

I'm seeing right now that the array length is limited to 334 (based on other array test).

Second image

Answer

It's very likely that the problem is how many variables are accepted in requests in your php.ini config. You should uncomment the ;max_input_vars = 100 to something like max_input_vars = 100000.

Hope it'll help.