Post ViewModel using KO.js

Topics: Writing modules
Nov 30, 2013 at 1:23 AM
Hi,

Im using Knockout JS to post data in controller, but I always receive null value even I passed values in KO
//Controller
[HttpPost]
public JsonResult saveMall(MallRecord mallRecord)
{
   //mallRecord is always null
}

//KO
var mallViewModel =
{
    Mall_Id: self.Mall_Id ,
    Mall_Name: self.Mall_Name
};

        $.ajax({
            url: '/mall/saveMall',
            cache: false,
            type: 'POST',
            datatype: "json",
            data: {
                __RequestVerificationToken: token,
                Mall: ko.toJSON(mallViewModel)
            },
            success: function (data) {
                $('#modalForm').modal('hide');
            }
        });
But if I tried to change the parameter datatype of my controller to:
public JsonResult saveMall(int mallID, string mallName)
{
}
I can get the right value I passed, I cant list all the parameters in the Controller because I have many fields to passed.


Thank You