Sencha Toch MVC - scripttag代理 - 无尽的加载

时间:2011-10-26 19:56:53

标签: model-view-controller proxy sencha-touch

JsonDaten的负载不起作用。它只显示加载通知

Model.js:

ps.models.Event = Ext.regModel("ps.models.Event", {
    fields: [
        {name: "id", type: "int"},
        {name: "date", type: "string"},
        {name: "kat", type: "string"},
        {name: "name", type: "string"},
        {name: "location", type: "string"},
    ]
});

ps.stores.event = new Ext.data.Store({
    model: "ps.models.Event",
    proxy: {
        type: 'scripttag',
        url: 'http://www.asfdasdf.com/eventkalender/eventlist/format/json',
        reader: {
            type: 'json'
        }
    },
    autoLoad: true
});

View.js:

items: [{
    xtype: 'list',
    emptyText: 'Keine Events verfügbar',
    itemTpl: '{name}',
    //grouped: true,
    scroll: 'vertical',
    fullscreen: true,
    store: ps.stores.event
}

怎么了?

感谢您的支持!!

2 个答案:

答案 0 :(得分:0)

可能这是因为json格式不正确(您可以通过在Chrome中按CTRL + Shift + J来检查错误) 请尝试按照本教程http://www.sencha.com/learn/legacy/Tutorial:Creating_JSON_Data_in_PHP

进行操作

更新

您需要向代理的读者添加root:'events'

ps.stores.event = new Ext.data.Store({
    model: "ps.models.Event",
    proxy: {
        type: 'scripttag',
        url: 'http://www.asfdasdf.com/eventkalender/eventlist/format/json',
        reader: {
            type: 'json',
            root: 'events'
        }
    },
    autoLoad: true
});

答案 1 :(得分:0)

您可能还想通过以下方式解决任何错误和超时:

ps.stores.event = new Ext.data.Store({
    model: "ps.models.Event",
    proxy: {
        type: 'scripttag',
        url: 'http://www.asfdasdf.com/eventkalender/eventlist/format/json',
        reader: {
            type: 'json',
            root: 'events'
        },
        timeout: 3000, //milliseconds
        listeners: {
            exception:function(proxy, response){
                 console.error(response.responseText);
            }
        }
    },
    autoLoad: true
});