I have some issue with ajax POST method. I spent two days looking for what could be the problem. I tried to send large string to my PHP server. But the server didn't receive the POST data. I made a little test script to reproduce the bug.
Here is my script who sends a large string to my server with POST method.
var click = function ()
{
//base_string (1 024 octets)
var base_string = "aaaaaaaa ... aaaa";
var big_string = "";
for (i = 0; i < parseInt($("#size").val());i++)
{
big_string += base_string;
}
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(evt) {
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
percentComplete = parseInt(percentComplete * 100);
console.log(percentComplete + "%");
}
}, false);
return xhr;
},
url: "test.php",
type: "POST",
data: {
data: big_string,
normal : "LOL"
},
dataType: "text",
success: function(_result) {
console.log("result\n" + _result);
}
});
}
And here is my PHP script to see if PHP see my POST data.
<?php
foreach ($_POST as $key => $value)
{
echo "{$key} = {$value}\r\n";
}
?>
When I try to send my 1ko string more than 978 times, the server don't receive my POST variable. But see the "normal: 'LOL'" variable.
So I also checked my PHP.ini and here's its configuration :
max_input_vars = 10000
post_max_size = 64M
suhosin.memory_limit=256M
suhosin.log.syslog=511
suhosin.executor.include.max_traversal=5
suhosin.post.max_vars=10000
suhosin.request.max_vars=5000
suhosin.request.max_varname_length=80
suhosin.request.max_totalname_length=300
suhosin.cookie.max_name_length=80
suhosin.post.max_array_index_length=80
suhosin.post.max_name_length=80
suhosin.get.max_array_index_length=80
suhosin.get.max_name_length=80
Do you have any idea on how to fix it ?