问题
Problem overview:
I am trying to adapt a kendo UI data-binding example to use my own jsonp request.
Detailed Description:
I am basing my project off of a data-binding example here. I created this jsfiddle , which represents the correctly working example I wish to emulate.
I am hoping to utilize JSONP according to the kendo datasource docs. I am relying upon this json api plugin for wordpress.
I know the json query works when I put this : http://www.techhelix.com/?json=get_post&id=1/
into the browser.
My attempted adaptation is published here on jsfiddle. The results yields no visible markup. But when I look in firebug, under the net panel, I see the following:
...so it seems like the JSON data is succesfully received.In contrast, the fully functional example from kendo yields a slightly different structure of JSON data, as shown here:
Conclusion:
I don't understand why my adaptation is not functioning as I expect. I realize that I might need to adjust the html markup in the kendo template, but first I would at least like to see at least some of the json data rendered as html. I suspect that the differing json structure may be important here.
回答1:
The Kendo UI DataSource works with arrays of items and expects such responses to be returned from the remote service. The service you are using return as single object hence the problem. Fortunately this is easily fixable by specifying a custom schema.data
:
schema: {
data: function(response) {
return [response.post];
}
}
Here is the updated jsFiddle: http://jsfiddle.net/892Yu/8/
来源:https://stackoverflow.com/questions/22216422/kendo-ui-jsonp-example-with-wordpress-json-plugin