Используя jquery, я могу отправлять объекты json с клиента на сервер, используя ajax:
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
});
Работает хорошо. Но если строка JSON становится намного больше (не точно точный размер, но где-то в 5 раз больше), данные $ _POST, полученные сервером, будут пустыми. Кто-нибудь знает почему?
Я использую Apache / PHP / jquery. Это происходит как из IE, так и из Firefox. Где-то мне нужно настроить конфиг?
Вот пример строки, которая не может пройти через:
{"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":""}],}]}]}
Он создан с использованием "stringify" на json.org:
var strJSON = JSON.stringify(oEvent);
EDIT:
В дальнейшем, я изменил dataType на «текст» и попытался отправить длинную строку чисел. Он работает до ~ 3500 символов, затем дросселирует (и когда я говорю «дроссель», я имею в виду, что запрос приходит на сервер с нулевым $ _POST.)
Мой PHP post_max_size - 64M, так что это не так. Кто-то предложил использовать «LimitRequestBody» Apache, которого нет в httpd.conf, поэтому я добавил к нему «LimitRequestBody 0» и перезагрузил Apache. Это тоже не помогло.
Любые другие предложения ???