Using jquery, I'm able to send json objects from client to server using ajax like this:
var strJSON = '{"event":[{
"dates":[
"2009-10-14","2009-10-15"],
"teams":[
{"id":"0","country":"USA","state":"CA","name":"California Polytechnic State University","subteam":""},
{"id":"1","country":"USA","state":"CA","name":"California State University, Bakersfield","subteam":""},
{"id":"2","country":"USA","state":"CA","name":"California State University, Fresno","subteam":""},
{"id":"3","country":"USA","state":"CA","name":"California State University, Fullerton","subteam":""}]
}]}';
$.ajax({
url: '../ajax/save_event',
type: 'POST',
data: { data : strJSON },
dataType: 'json',
timeout: 8000,
cache: false
});
It works well. But if the JSON string gets much bigger (not sure the exact size, but somewhere around 5x bigger), the $_POST data received by the server is empty. Anybody know why?
I'm using Apache/PHP/jquery. It happens from both IE and Firefox. Is there a config setting somewhere I need to adjust?
Here's an example of a string that fails to make it through:
{"events":[{"dates":["2009-10-10","2009-10-11","2009-10-12"],"divisions":[{"level":"Collegiate","name":"Varsity","subdivision":"Division I","rounds":[],"teams":[{"id":"0","country":"USA","state":"CA","name":"California Polytechnic State University","subteam":""},{"id":"1","country":"USA","state":"CA","name":"California State University, Bakersfield","subteam":""},{"id":"2","country":"USA","state":"CA","name":"California State University, Fresno","subteam":""},{"id":"3","country":"USA","state":"CA","name":"California State University, Fullerton","subteam":""},{"id":"4","country":"USA","state":"CA","name":"Stanford University","subteam":""},{"id":"5","country":"USA","state":"CA","name":"University of California, Davis","subteam":""},{"id":"6","country":"USA","state":"CA","name":"San Francisco State University","subteam":""},{"id":"7","country":"USA","state":"CA","name":"Lassen Community College","subteam":""},{"id":"8","country":"USA","state":"CA","name":"Menlo College","subteam":""},{"id":"9","country":"USA","state":"CA","name":"Fresno Pacific University","subteam":""},{"id":"10","country":"USA","state":"CA","name":"Bakersfield","subteam":""},{"id":"11","country":"USA","state":"CA","name":"Buchanan","subteam":""},{"id":"12","country":"USA","state":"CA","name":"Campolindo-Moraga","subteam":""},{"id":"13","country":"USA","state":"CA","name":"Fremont-Sunnyvale","subteam":""},{"id":"14","country":"USA","state":"CA","name":"Ponderosa-Shingle Springs","subteam":""},{"id":"15","country":"USA","state":"CA","name":"West Covina","subteam":""},{"id":"16","country":"USA","state":"CA","name":"Gilroy","subteam":""},{"id":"17","country":"USA","state":"CA","name":"San José State University","subteam":""},{"id":"18","country":"USA","state":"CA","name":"University of California, Los Angeles","subteam":""},{"id":"19","country":"USA","state":"CA","name":"Sierra College","subteam":""},{"id":"20","country":"USA","state":"CA","name":"Selma","subteam":""},{"id":"21","country":"USA","state":"CA","name":"Liberty","subteam":""}],}]}]}
It's created using json.org's "stringify":
var strJSON = JSON.stringify(oEvent);
EDIT:
Investigating further, I changed the dataType to "text" and tried sending a long string of numbers. It works up until ~3500 characters then chokes (and when I say "choke" I mean that the request arrives at the server with a null $_POST.)
My PHP post_max_size is 64M, so that's not it. Someone suggested using Apache's "LimitRequestBody" which wasn't in httpd.conf, so I added "LimitRequestBody 0" to it and rebooted Apache. That didn't help either.
Any other suggestions???
See Question&Answers more detail:
os