Reputation: 260
I am trying to send an array of objects (Which I succesfully extract from a Handsontable) to a script in my PHP server.
function saveMaterials(showAlert){
var tableData = handsontable.getData();
$.ajax({
url: "../phprequests/saveMaterials.php",
data: { "data": tableData,
"endUserId": <?php echo $endUserId ?>},
dataType: 'json',
type: 'POST',
success: function (res) {
if (res.result === 'ok') {
if(showAlert) alert('Saved data.');
}
else {
if(showAlert) alert(res.errorMessage);
}
},
error: function(xhr, status, error) {
if(showAlert) alert(error);
}
});
}
In my PHP server, I will just receive the data, and save in in my DB:
<?php
$materialsData = $_POST['data'];
$endUserId = $_POST['endUserId'];
//deal with materialsData
?>
materialsData is an array of objects (rows of the Handsontable), which have about 15 fields each (One for each column).
When I have a small number of rows, everything works as expected. However, after sending more than 80 rows at a time, I noticed my PHP is receiving only 72 items of the materialsData array, and the "endUserId" part of the data is not received as well. Looks like, for some reason, only part of the data was sent to the server, or received by it.
Is there a limit for the data lenght I can send on this post request? I checked max_post_size in my server, and it's set to 256MB.
Upvotes: 1
Views: 390
Reputation: 260
Solved the problem by increasing max_input_vars in my server's php.ini file
Since I had more than 1000 variables in the array, only part of them was received by the server!
Hope this helps someone!
Upvotes: 2