Sencha touch 在Sencha Touch 2的商店中使用代理

Sencha touch 在Sencha Touch 2的商店中使用代理,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,这个项目的目标是加载由web服务器上的脚本输出的Json,这样我就可以在Sencha Touch 2中的列表中显示数据 我已经看过无数的例子,包括这个网站上其他人的问题的答案,但我似乎仍然不知道我的代码有什么问题。我确信这是一个很小的问题,或者是一些我不知道的规则,但我希望有人能给我指出正确的方向 这是我的模型: Ext.define('Sencha.model.Location', { extend: 'Ext.data.Model', config: { fi

这个项目的目标是加载由web服务器上的脚本输出的Json,这样我就可以在Sencha Touch 2中的列表中显示数据

我已经看过无数的例子,包括这个网站上其他人的问题的答案,但我似乎仍然不知道我的代码有什么问题。我确信这是一个很小的问题,或者是一些我不知道的规则,但我希望有人能给我指出正确的方向

这是我的模型:

Ext.define('Sencha.model.Location', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['name','location','open','details']
    }
});
这是我的商店:

Ext.define('Sencha.store.Locations',{
    extend: 'Ext.data.Store',
    requires:[
        'Sencha.model.Location',
    ],
    config: {
        model: 'Sencha.model.Location',
        storeId: 'Locations',
        proxy: {
      type: 'ajax',
      url : 'http://url/to/locations.php?filetype=.json',
      reader: {
        type: 'json',
      },
      autoLoad: 'true'
    }
    }
});
以下是我希望它显示的视图:

Ext.define('Sencha.view.LocationList',{
    extend: 'Ext.List',
    alias: 'widget.LocationList',
    xtype: 'locationlist',
    config: {
        title: 'What\'s Open @CU',
        disableSelection: true,
        itemTpl: '<img src="http://localhost/{open}.png" style="width:16px;height:16px;margin-right:8px;" />{name}<span style="font-size:9pt;margin-left:8px;color:#888;">{location}</span>',
        store: 'Locations',
        onItemDisclosure: true
    }
});

读取器中添加
rootProperty:“业务”
:{ 键入:“json”, rootProperty:“企业” }

http://url/to/locations.php 
与sencha touch应用程序位于同一位置?
如果不是,则需要JsonP代理。JsonP将Json数据包装到类似函数的上下文中以使其可用。

您的Json无效。你忘了逗号:

{
"businesses":
    {
    "name" : "Baker's",
    "location" : "4th Foor Uni Centre",
    "open" : "open",
    "details" : "This is some information."
    }
}
此外,如果您打算发送多个业务,您可能希望将JSON格式更改为以下格式:

{
"businesses":[
    {
    "name" : "Baker's",
    "location" : "4th Foor Uni Centre",
    "open" : "open",
    "details" : "This is some information."
    },
    {
    "name" : "Baker's",
    "location" : "4th Foor Uni Centre",
    "open" : "open",
    "details" : "This is some information."
    }
    ...
]
}
然后像nuthan说的那样,在you's proxy的阅读器中添加
rootProperty:“企业”


希望这有帮助

那么企业就必须是一个JSON对象数组,我最初就有这个数组,但这没有什么区别。问题解决了,下面的回答者指出了一大堆问题。谢谢你在同一个域中的“guysIs”?没有CORS问题?谢谢,逗号绝对是问题的一部分!我还改变了JSON的生成方式,并使用了JsonP,正如上面的一个答案所建议的那样。在我看来似乎很愚蠢,它会默默地失败,而不告诉您它发现了Json的问题,他们其余的错误捕获是如此的好!谢谢你的回答:)我最终使用了JsonP。我已经到了使用ajax可以工作的地步,但是对于发布版,我计划在不同的服务器上输出json,所以我不得不学习如何使用JsonP。谢谢:)
{
"businesses":[
    {
    "name" : "Baker's",
    "location" : "4th Foor Uni Centre",
    "open" : "open",
    "details" : "This is some information."
    },
    {
    "name" : "Baker's",
    "location" : "4th Foor Uni Centre",
    "open" : "open",
    "details" : "This is some information."
    }
    ...
]
}