【发布时间】:2014-01-08 21:16:09
【问题描述】:
我有以下代码从另一个域检索 JSON 结构并将其显示在页面上。
但是,什么都没有出现,我在控制台中收到此错误:
Uncaught SyntaxError: Unexpected token : People.json:2
我已将我的 JSON 传递给 JSON 验证器,它返回为有效。
这是我的代码:
Ext.define("Person", {
extend: "Ext.data.Model",
config: {
fields: [
{ name: 'Id', type: 'int'},
{ name: 'Name', type: 'string'},
{ name: 'Email', type: 'string'}
]
}
});
var myStore = Ext.create("Ext.data.Store", {
model: "Person",
proxy: {
type: "jsonp",
url: 'http://example.com/People.json',
reader: {
type: "json",
rootProperty: "Person"
}
},
autoLoad: true
});
Ext.create("Ext.List", {
fullscreen: true,
store: myStore,
itemTpl: "{Name}, {Id}"
});
这是我的 JSON 文件的内容:
{
"Person": [
{
"Id": 0,
"Name": "Robert Lara",
"Email": "rolara@example.com"
},
{
"Id": 1,
"Name": "Tom Hicks",
"Email": "tohicks@example.com"
}
]
}
【问题讨论】:
标签: javascript json extjs sencha-touch cross-domain