Not able to send Json data to controller method using $Post

100 Views Asked by At

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?

0

There are 0 best solutions below