Answer the question
In order to leave comments, you need to log in
How many elements can be passed in an array via ajax?
Hi all! Help with advice
JS collect JSON array and transfer it with AJAX. I accept and process PHP. the crux of the problem is that PHP only accepts 100 elements, while an array can have 40 or more.
how to be? and what could be the problem (hoster restrictions?)?
var objJSONSave = [];
$(".my_snippets ").each(function (i, e) {
console.log('массив для сохранения');
objJSONSave.push
({
key: $(e).find(".my_key").text(),
search: $(e).find(".my_search").text(),
url: $(e).find(".my_url").text(),
sitename: $(e).find(".my_sitename").text(),
snippet: $(e).find(".my_snippet").text(),
poz: $(e).find(".my_poz").val(),
neg: $(e).find(".my_neg").val(),
type: $(e).find(".my_type").val(),
action: $(e).find(".my_action").val(),
pos: $(e).find(".my_pos").val()
});
});
objJSONSave.push
({
dateadd: $('#dateadd').val(),
dateprev: $('#dateprev').val(),
id: $('#getId').val(),
link: $('#linkM').val(),
project: $('#project').val()
});
$.ajax({
type: "POST",
url: "./tpl/save.php",
async: true,
data: {obj: objJSONSave},
success: function (data) {
if (data != '') {
alert('all good!');
$('#qw').append(data);
console.log(objJSONSave);
}
}
});
$postData = $_POST;
Answer the question
In order to leave comments, you need to log in
Well, send a json string to the server, it has at least 2000 values. The main thing is to get into the limits on the size of the request body. As a rule, this is about 5 MB (less often 10-20), depending on the server settings. If there are still a lot of values, either raise the limits on the receiving host (easiest) or send in chunks (harder).
Good morning.
Look here .
There is a magic line in php.ini: max_input_vars = 1000
Exactly 1000 {value: variable} pairs are passed
The number of elements is less important than the total size of the POST request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question