【发布时间】:2012-01-05 05:07:51
【问题描述】:
我正在尝试将外部 json 加载到 Sencha Touch 应用程序中。我可以在应用程序中定义我的数据,或者使用外部 json 文件,一切都很好。然后我将我的 json 文件移动到删除服务器,将我的代理更改为 type: 'scripttag' 以处理 jsonp 问题,然后我遇到了问题。当我查看我的页面资源时,我看到 json 文件确实加载了,但它并没有像我的本地 json 文件那样填充我的列表。
使用本地 json 文件(这个可行)
var jsonStore = new Ext.data.Store({
model: "Person",
proxy: {
type: 'ajax',
url: 'http://dev.liftstudios.ca/data.json',
reader: {
type: 'json'
}
},
autoLoad: true
});
var jsonPanel = {
title: "json",
items: [
{
xtype: 'list',
store: jsonStore,
itemTpl:itemTemplate,
singleSelect: true
}
]
};
使用相同的 json 文件,从远程主机加载。
这会加载文件,但不会填充列表。
var jsonStore = new Ext.data.Store({
model: "Person",
proxy: {
type: 'scripttag',
url: 'http://www.server.com/data.json',
reader: {
type: 'json'
}
},
autoLoad: true
});
var jsonPanel = {
title: "json",
items: [
{
xtype: 'list',
store: jsonStore,
itemTpl:itemTemplate,
singleSelect: true
}
]
};
我可能在这里遗漏了一些简单得令人尴尬的东西,但我不确定那是什么。任何帮助将不胜感激。
【问题讨论】:
标签: extjs sencha-touch jsonp