我无法弄清楚我做错了什么,这段代码
url = '?D=cp&C=addons_modules&M=show_module_cp&module=myaddon&method=test';
var selections = [1,2,3,4];
processBegin();
$.post(url, {ids: selections}, function(data) {
alert(data)
},
"json");
返回NULL,但是如果我发送它(没有{ids:selections})
url = '?D=cp&C=addons_modules&M=show_module_cp&module=myaddon&method=test';
var selections = [1,2,3,4];
processBegin();
$.post(url, function(data) {
alert(data)
},
"json");
运作良好。我做错了什么?
由于
Http标题
http://eeclean/system/index.php?D=cp&C=addons_modules&M=show_module_cp&module=myaddon&method=test&products=
POST /system/index.php?D=cp&C=addons_modules&M=show_module_cp&module=myaddon&method=test&products= HTTP/1.1
Host: eeclean
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: */*
Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 47
Cookie: exp_last_visit=1327226896; exp_last_activity=1327235643; exp_sessionid=331607e53eef40182ecaac80c9a42e66ecc9ebb7; PHPSESSID=f8a8bf96541f0dcbf56645ccc83311e3; exp_anon=1; exp_expiration=1327235644
Pragma: no-cache
Cache-Control: no-cache
ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3&ids%5B%5D=4
答案 0 :(得分:1)
您应该序列化js数组以将其作为参数发布或以字符串形式发送。(使用其他方式)
var selections = [1,2,3,4];
像这样:
$.post(url, {'ids[]': selections}, function(data) {
alert(data)
},