I read some data via Ajax as follows.
This works perfectly. Then I try to do the same with a datasource.
As it fails, I also tried to remove the "JSON.stringify". However, that one also fails. Looking at the request's body with Fiddler, I see
Michael G. Schneider
var
data = {
id: 4711,
task: {
name:
"coding"
}
};
var
options1 = {
type:
"POST"
,
dataType:
"json"
,
contentType:
"application/json"
,
data: JSON.stringify(data)
};
$.ajax(
"/api/Person/"
, options1);
This works perfectly. Then I try to do the same with a datasource.
var
options2 = {
transport: {
read: {
url:
"/api/Person/"
,
type:
"POST"
,
dataType:
"json"
,
contentType:
"application/json"
,
data: JSON.stringify(data)
}
}
};
var
datasource =
new
kendo.data.DataSource(options2);
datasource.read();
As it fails, I also tried to remove the "JSON.stringify". However, that one also fails. Looking at the request's body with Fiddler, I see
Reading via Ajax
{"id":4711,"task":{"name":"coding"}}
Reading via Datasource (with stringify)
0=%7B&1=%22&2=i&3=d&4=%22&5=%3A&6=4&7=7& (rest stripped)
Reading via Datasource (without stringify)
id=4711&task%5Bname%5D=coding
Michael G. Schneider