【发布时间】:2012-02-06 02:58:05
【问题描述】:
此 JSON 通过 jsonlint 验证。然而 Firefox 和 Chrome 拒绝它:
{
"messages": [
{
"subject": "One"
},
{
"subject": "Two"
},
{
"subject": "Three"
}
],
"totalResults": 10
}
错误消息是“消息”上的“无效标签”。
这是它的加载方式:
var store = Ext.create('Ext.data.Store', {
model: 'MyModel',
autoLoad: true,
pageSize: 3,
proxy: {
type: 'jsonp',
url: 'http://localhost:8080/document-viewer-1.0/testdata.json',
reader: {
root: 'messages',
totalProperty: 'totalResults'
}
}
});
回答:
这是我自己的愚蠢错误。我没有将 JSONP 回调名称放在 JSON 文件结构周围。
【问题讨论】:
-
JSON 有效。 jsonlint.com
标签: javascript json validation syntax-error jsonlint