How do I send the object constructed using kendo.data.Model back to ASP.MVC?
For example, a person object is create using the kendo.data.Model using the code below
My first question - How do I use a $.Ajax() to send the object back to my ASP MVC action (e.g AddPerson)?
My second question - How do i bind the receive model on the server side code?
For example, a person object is create using the kendo.data.Model using the code below
var
Person = kendo.data.Model.define( {
id:
"personId"
,
// the identifier of the model
fields: {
"name"
: {
type:
"string"
},
"age"
: {
type:
"number"
}
}
});
var
person =
new
Person( {
name:
"John Doe"
,
age: 42
});
function
addPerson(person) {
$.ajax({
url:
"/Person/Add/"
});
}
My second question - How do i bind the receive model on the server side code?
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult Add([DataSourceRequest] DataSourceRequest request, Person person)
{
// Code to add person to database.
}