2012-01-22 60 views
0

工作,我想不出什麼我做錯了,該代碼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,但如果我送這個(不{IDS:選擇})

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 

回答

1

你應該serealize JS數組將它張貼作爲PARAM或將其作爲字符串(用另一種方式)

var selections = [1,2,3,4]; 

是這樣的:

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

沒有幫助,我trie d這個 –

+0

你有一個有效的網址嗎?你的網址是從''開始的? – Oyeme

+0

它是有效的網址,以及它沒有{'ids []':選擇}, –