我想存储来自另一个域的 json 对象数组。我已经尝试了代理中所有可能的配置,但仍然无法正常工作。所以请帮帮我。
响应数组:
[
{
"id": 1,
"title": "Take A Bow",
"artist": "Rihanna",
"cover": "resources/images/cd-covers/take-a-bow.jpeg",
"audio": "http://home.no/hamed2ganja12/Single/Rihanna%20-%20Take%20A%20Bow%20%28www.Iran2Music.Org%29.mp3"
},
{
"id": 2,
"title": "Ridin' Solo",
"artist": "Jason Derulo",
"cover": "resources/images/cd-covers/ridin-solo.jpeg",
"audio": "http://ms11.cyworld.com.cn/d044/2010/05/01/167/1272686567306986_file.mp3"
},
{
"id": 3,
"title": "Hero",
"artist": "Nickelback",
"cover": "resources/images/cd-covers/hero.jpeg",
"audio": "http://api.ning.com/files/hXzO1QWnGr6ZgtB05IbaLW5IId7mjLPvOMGA0I8JHY*u*ZMCrczyw*XZrimUE7XQHFHgOLWa2b8s0xGfoHg5nRs-J84KlSGO/NickelBackHeroSpidermanTheme.mp3"
}]
模型:
Ext.define('MyApp.model.Track', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'title', type: 'string' },
{ name: 'artist', type: 'string' },
{ name: 'cover', type: 'string' },
{ name: 'audio', type: 'string' }
]
}
});
店铺:
Ext.create('Ext.data.Store',{
requires:['MyApp.model.Track'],
autoLoad:true,
model:'MyApp.model.Track',
storeId:'myStore',
autoSync:true,
fields:["title","artist"],
proxy:{
type:'jsonp',
url: 'http://www.tux-components.com/examples/playlist/app/music.json',
reader: {
type: 'json'
}
},
listeners:{
load: function(store, records, successful,operation,eOpts){
console.log('loaded records count is '+store.getCount());
}
}
});
我发现它给出了超时错误。但 URL 在浏览器中运行良好。接下来我该怎么办?请帮我..