即時通訊嘗試獲取所有選中的複選框的值並將這些值(整數)發佈到操作結果,問題是我在控制器端得到一個空數組... my jQuery的代碼如下:不能得到陣列我的行動結果
function getIds() {
var idList = new Array();
var loopCounter = 0;
//find all the checked checkboxes
$("input:checked").each
(
function() {
//fill the array with the values
idList[loopCounter] = $(this).val();
loopCounter += 1;
}
);
//Send the list off
alert(idList);
var postData = { values: idList };
$.post("/Admin/Delete/", postData);
}
我控制器端代碼以下
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Delete(Int32[] values)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("NewSubDashboard");
}
catch
{
return View();
}
}
沒有與發佈,但即時通訊剛開在控制器側空數組沒有問題... ...
參數名稱是什麼?如果您使用該名稱作爲操作的參數名稱,則不需要上述代碼。 – Oded 2010-11-25 15:30:54