My javascript
function SaveData(status) {
var reserved = [];
var id = -1;
$('#fdEitDetail').find('table tr').each(function (index, item) {
var isChk = $(item).find('input:checkbox').is(':checked') ? 0 : 1;
id = $(item).attr('name');
reserved.push({ ID: $(item).attr('id'), IsChecked: isChk, Comment: $(item).find('textarea').val() });
});
var dataset = JSON.stringify({ checkList: reserved, status: status, machineID: id });
$.ajax({
url: '/Home/UpdateData',
contentType: "application/json; charset=utf-8",
type: 'POST',
data: dataset,
success: function (result) {
alert(result);
}
});
}
I am calling this controller action:
public JsonResult UpdateData(string checkList, int status,int machineID)
{
var response =
new JavaScriptSerializer().Deserialize<List<PMICheckListRequest>>(checkList);
return Json("value = Success");
}
the class
public class PMICheckListRequest
{
public int ID { get; set; }
public int IsChecked { get; set; }
public string Comment { get; set; }
}
In the controller action is being hit from the ajax request both of this parameterstatus, machineID has the value that i set in javascript but checkList is null always.