I need to pass a value to an MVC action,
below is the JavaScript code:
function functionName(Name) {
$.ajax({
url: "/Home/GetName",
type: "POST",
dataType: "json",
data:JSON.stringify({
Name: Name
}),
success: function (mydata) {
}
});
return false;
}
and here is the corresponding MVC action:
[HttpPost]
public JsonResult GetName(string Name)
{
return Json(new { oid = Name});
}
Despite successfully printing the value "Name" before sending it to the action, it is received as "null" on the server.