jquery - JSON Object Properties are coming as NULL -
i have kendo ui grid in asp.net mvc. trying pass json object controller. though getting object in controller, properties coming null (firstname, lastname). how can correct it?
note: object not null; properties null in object
json
var newperson = new object(); newperson.firstname = "a"; newperson.lastname = "b"; var json1 = { myperson: newperson }; return json1; javascript
$("<div/>").appendto(e.detailcell).kendogrid({ datasource: { type: "aspnetmvc-ajax", transport: { datatype: "json", //,type: "post" read: { url: "home/getitemsdata", data: function () { var newperson = new object(); newperson.firstname = "a"; newperson.lastname = "b"; var json1 = { myperson: newperson }; return json1; } } }, schema: { model: { fields: { program: { itemid: "number", }, itemdescription: { type: "string" } } }, total: "total", data: "items" }, serverpaging: true, serversorting: true, serverfiltering: true, pagesize: 5 }, scrollable: false, sortable: true, pageable: true, columns: [ { field: "itemid", title: "item id", width: "70px" }, { field: "itemdescription", title: "item description", width: "110px" } ] }); controller
public jsonresult getitemsdata(person myperson, [datasourcerequest] datasourcerequest request) { }
if understood correctly, code similar this:
var x = function (){ return "foo"; }; here, x not contain foo, contains function reference. need execute function in order return value:
var x = (function (){ return "foo"; })(); here, x contain foo.
Comments
Post a Comment