【发布时间】:2011-11-21 14:35:03
【问题描述】:
我被这段代码卡住了,我从 Youtube API 获取这个 json 格式的数据,如果我使用 type:'json' 它将失败,因为跨域的事情,但其他元素无论如何都会加载;然后,如果我将 type: 更改为 'jsonp' (这是 ExtJS API 上描述的语法),它会给我这个错误:“Uncaught TypeError: Cannot call method 'substring' of undefined” 我尝试设置 type:'anyotherstupidthing'同样的事情也会发生,那么会发生什么?
这是我当前的数据模型和我的商店:
Ext.define('Video', {
extend: 'Ext.data.Model',
fields: ['id', 'title']
});
myStore2 = Ext.create('Ext.data.Store', {
model: 'Video',
proxy: {
type: 'ajax',
url : 'http://gdata.youtube.com/feeds/api/videos?q=surfing&v=2&alt=jsonc',
reader: {
type: 'jsonp',
root: 'items'
}
}
});
提前致谢! 编。
【问题讨论】: