I am new to .Net MVC. I am trying to send some data from my view to the controller.
Controller Code:
[HttpPost]
public ActionResult Add(string json)
{
//more code here
}
JS:
function SaveDetails() {
var details= {
"Code": "test",
"Desc": "Testing",
"Xclude": "N"
};
$.ajax({
type: "POST",
async: true,
url: "Add",
contentType: 'application/json',
dataType: "json",
data: JSON.stringify(details),
success: function (){
$('#Code').val("");
$('#Desc').val("");
$('#Xclude')[0].checked = false;
}
});
}
But when I debug the code, the variable json in the controller is getting null value and not the data I am passing to it. I am not able to identify what is wrong here. Any help would be much appreciated.