Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery post不能与参数一起使用_Jquery - Fatal编程技术网

jquery post不能与参数一起使用

jquery post不能与参数一起使用,jquery,Jquery,我不知道我做错了什么,这个代码 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,但如果我发送此消息(不带{i

我不知道我做错了什么,这个代码

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})

工作顺利。我做错了什么

谢谢

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

您应该序列化js数组,将其作为参数发布或作为字符串发送。(使用另一种方式)

像这样:

$.post(url, {'ids[]': selections}, function(data) {
    alert(data)
},

你有一个有效的url吗?你的url从一个“?”开始?它是有效的url,并且在没有{'ids[]':selections}的情况下工作,你能告诉我你在服务器端脚本上有什么。你可以这样测试它:“echo json_encode(array('succ'=>1));奇怪的是,它似乎没有执行那个url。它应该调用myaddon类的函数测试,但它没有看到,你能告诉我你在服务器端返回了什么数据吗?
var selections = [1,2,3,4];
$.post(url, {'ids[]': selections}, function(data) {
    alert(data)
},