I have a model I am passing to a view and using Html.Raw to encode it into a JSON object:
var model = @Html.Raw(Json.Encode(Model));
On the pa
Change you code to
$.ajax({
type: 'POST',
url: '@Url.Action("AddProducts")',
data: model, // not stringified
dataType: 'json',
....
or
$.post('@Url.Action("AddProducts")', model, function(data) {
// do stuff with returned data
});
which will post back to
[HttpPost]
public ActionResult AddProducts(ProductModel model)
{
//do stuff with the model data
}
assuming the model in your view is ProductModel
However, if your just wanting to post back the form, you can use var model = $('form').serialize();
rather than manually setting the properties of the object.