I am trying to send Json data to my controller method using $.post of Jquery.
Js code :
$.post(saveUpdateActionurl, JSON.stringify({ 'name': "John", 'time': "2pm" }), function (data) {
_this.afterSave(data);
}, "json");
Controller Method :
[HttpPost]
public ActionResult ControllerMethod(Test data)
{
return null;
}
public class Test
{
public string name {get;set;}
public string time {get;set;}
}
The controller method parameter receives null for the property name and time. I am not using form in UI so cant use the form collection. How to resolve this?