I have a form whose data I want to be passed to my controller. This is the JQuery call that I am making -
var data = $form.serializeArray();
var options = {
contentType: "application/json",
url: "/Form/Save",
data: JSON.stringify(data),
type: "post",
datatype: "html",
success: function (result, xhr, status) {
console.log(result);
},
error: function (xhr, status, error) {
// redirect to error page
}
};
$.ajax(options);
And this is how I am recieving this in controller -
public ActionResult Save(string paramJson)
{
// save paramJson
return null;
}
But all I am recieving in Save action is paramJson = null. I tried below as well -
data: JSON.stringify({paramJson: data})
but it didn't work. What should be done here?