使用
jquery,我可以使用ajax将json对象从客户端发送到服务器,如下所示:
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字符串变得更大(不确定确切的大小,但是大约5x的地方),服务器接收的$_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":""}],}]}]}
它使用json.org的“stringify”创建:
var strJSON = JSON.stringify(oEvent);
编辑:
进一步调查,我将dataType更改为“text”,并尝试发送一长串数字.它工作直到〜3500个字符,然后扼制(当我说“扼制”我的意思是请求到达服务器一个空的$_POST.)
我的PHP post_max_size是64M,所以不是这样.有人建议使用Apache的“LimitRequestBody”,它不在httpd.conf中,所以我添加了“LimitRequestBody 0”并重新启动了Apache.那也没有帮助.
任何其他建议?