My Ajax function:
function changeMultipleItemStatus(status) {
var ids= getAllCheckedIds();
var comment = $('#txtComment').val();
$.ajax({
type: 'POST',
url: "../Admin/ChangeMultipleItemStatus",
cache: false,
data: {
ids: ids,
status: status,
comment: comment
},
traditional: true,
success: function (html) {
...
}
}); }
ActionResult
[HttpPost]
public ActionResult ChangeMultipleItemStatus(int[] ids, string status, string comment)
{
....
}
function getAllCheckedIds() {
var data = [];
$("table input:checked").each(function () {
data.push($(this).val());
});
return data;
}
My problem is ActionResult Changemultiplestatus first variable ids is always null.
when i alert dataToSend it alert it seems okey (true,1,2) -> 1,2 is id of items.
But in controller action ids is always null.
any comments?
Can you change
int[]ids to string ids at webservice. Is it still null? Also try[ [System.Web.Services.WebMethod]]instead of[HttpPost]