c# - Ajax not posting data to controller -
i posting data through ajax action, problem not able data posted through ajax in controller action. while debugging, call gets transferred action dont in data not 'null'.
here ajax call,
$.ajax({ type: 'post', url:' @url.action("postamount", "deal")', data: { country: 2, amount: 4.02 }, datatype:json, success: function (data) { alert("hiiii"+data); } });
and action,
[httppost] public jsonresult postamount(int country,double amount) { allocationviewmodel mod = new allocationviewmodel(); return json(mod); }
try this:
var datatopost = "{ country:'" + 2 + "', amount:" + 4.02 + "}"; $.ajax({ url: @url.action("postamount", "deal")', type: "post", datatype: 'json', data: datatopost, cache: false, contenttype: "application/jsonrequest; charset=utf-8", success: function (data) { alert("hi"+ data); } });
Comments
Post a Comment