JSONP存储数据未显示在面板中

JSONP存储数据未显示在面板中

本文介绍了Sencha Touch JSONP存储数据未显示在面板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 sencha-touch 应用程序按照我认为的方式连接,并且在将其加载到Chrome中时,Javascript控制台不会引发任何错误. WebService最终返回了适当的数据,但是由于某种原因,我无法终生弄清楚面板为何空白.

I've got my sencha-touch app wired up as I believe it should be, and when I load it into Chrome, the Javascript console doesn't throw any errors. The WebService is finally returning the appropriate data, yet for some reason I can't for the life of me figure out why the panel is blank.

这是APP URL
http://rpcm.infinitas.ws/

Here's the APP URL
http://rpcm.infinitas.ws/

这是WebService URL
http://rpc.infinitas.ws/Vimeo/Read ?_dc = 1308083451839& limit = 25& callback = stcCallback1001

Here's the WebService URL
http://rpc.infinitas.ws/Vimeo/Read?_dc=1308083451839&limit=25&callback=stcCallback1001

这是一些相关代码.

CONTROLLER

rpc.controllers.VimeoController = new Ext.Panel(
    rpc.views.Vimeo.index
);

查看

rpc.views.Vimeo.index = {
    id: 'VideoView',
    title: 'Videos',
    tpl: rpc.templates.VimeoTemplate,
    iconCls: 'tv',
    dockedItems: [{ xtype: 'toolbar', title: 'Videos'}],
    store: 'rpc.stores.VimeoStore'
};

存储

rpc.stores.VimeoStore = new Ext.data.Store({
    id: 'VimeoStore',
    model: 'rpc.models.VimeoModel',
    proxy: {
        type: 'scripttag',
        url: WebService('Vimeo', 'Read'),
        method: 'GET',
        reader: {
            type: 'json',
            root: 'results'
        }
    },
    autoLoad: true
});

模型

rpc.models.VimeoModel = Ext.regModel('rpc.models.VimeoModel', {
    fields: [
        {name: 'id', type: 'int'},
        {name: 'title', type: 'string'}
    ]
});

模板

rpc.templates.VimeoTemplate = new Ext.XTemplate([
    '<tpl for=".">',
        '<div>',
            '{title}',
        '</div>',
    '</tpl>'
]);

JSON响应

任何帮助或指导将不胜感激.

Any help or direction will be greatly appreciated.

推荐答案

您提供的示例响应看起来像JSONP而不是纯JSON.您可能需要 Ext.data.proxy .JsonP .

The example response you provided looks like JSONP instead of plain JSON. You probably want an Ext.data.proxy.JsonP.

要使用此功能,您可以将商店更改为以下形式:

To use this, you could change your store to look like this:

rpc.stores.VimeoStore = new Ext.data.Store({
    id: 'VimeoStore',
    model: 'rpc.models.VimeoModel',
    proxy: {
        type: 'jsonp',
        url: WebService('Vimeo', 'Read'),
        reader: {
            type: 'json',
            root: 'results'
        }
    },
    autoLoad: true
});

祝你好运!

这篇关于Sencha Touch JSONP存储数据未显示在面板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 04:53