Kendo UI Jsonp示例与Wordpress JSON插件 [英] Kendo UI Jsonp example with wordpress json plugin

查看:152
本文介绍了Kendo UI Jsonp示例与Wordpress JSON插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改kendo UI数据绑定示例以使用我自己的jsonp请求.

I am trying to adapt a kendo UI data-binding example to use my own jsonp request.

我基于数据绑定示例这里.我创建了此jsfiddle ,它代表了我希望模仿的正确工作示例.

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.

我希望根据 kendo数据源使用JSONP文档.我依靠此json api插件进行wordpress.

I am hoping to utilize JSONP according to the kendo datasource docs. I am relying upon this json api plugin for wordpress.

当我将http://www.techhelix.com/?json=get_post&id=1/放入浏览器时,我知道json查询有效.

I know the json query works when I put this : http://www.techhelix.com/?json=get_post&id=1/ into the browser.

我尝试的改编已发布在jsfiddle上的 上.结果不会产生可见的标记.但是,当我在网络面板下查看Firebug时,会看到以下内容: ...因此似乎已成功接收到JSON数据.

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.

相反,kendo的功能齐全的示例产生的JSON数据结构略有不同,如下所示:

In contrast, the fully functional example from kendo yields a slightly different structure of JSON data, as shown here:

我不明白为什么我的适应功能没有达到我的预期.我意识到我可能需要调整kendo模板中的html标记,但是首先我至少希望至少看到一些以html形式呈现的json数据.我怀疑不同的json结构在这里可能很重要.

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.

推荐答案

Kendo UI数据源可处理一系列项目,并期望从远程服务返回此类响应.您正在使用的服务作为单个对象返回,因此出现了问题.幸运的是,可以通过指定自定义schema.data:

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];
                }
            } 

这是更新的jsFiddle: http://jsfiddle.net/892Yu/8/

Here is the updated jsFiddle: http://jsfiddle.net/892Yu/8/

这篇关于Kendo UI Jsonp示例与Wordpress JSON插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆