如何通过AJAX使用jQuery和PHP处理海量数据?

i am passing a huge javascript array to php via the $.ajax method of jquery. The Content-Type is JSON and i sent the data as RAW.

In PHP i get the data with file_get_contents('php://input').

Everything is working very well, but on huge javascript arrays, for example 2,5MB, php receives only the small vars and the huge vars are stripped out. Before i send the data with jquery i do a JSON.stringify to send the data as JSON. PHP still will strip out all huge vars in this JSON string and if i get the contents of "php://input" only the small vars are left over....

In the php.ini i have raised up the max_post_size and other stuff, but nothing will work...

Does anybody know how i can handle this right?

thx!

Probably not the best idea but you could split your data, somthing like (not tested, might need a few corrections):

var json = HUGEJSON;
while (json.length != 0) {
   var toSend = json.length >= 4096 ? json.substr(0, 4096) : json;
   $.ajax({
       url: 'server',
       method:'post',
       type:'json',
       data: toSend
   });
   json = json.length >= 4096? json.substr(4096, json.length-4096) : json;
}

Then find a way to rebuild the data server side until all the data have been send.