2013-04-21 103 views
2

我有一个代码,它给我的错误:无法调用“getProxy”的未定义XML阅读器不工作

var mystore = new Ext.data.Store({ 
    url: 'http://weather.yahooapis.com/forecastrss?w=2121267&u=c.xml', 
    // specify a XmlReader 
    reader: new Ext.data.XmlReader({ 
    record: 'channel', 
    fields:[ 
      { name: 'title', type: 'string', mapping:'title'} 
     ] 
    }) 
}); 
mystore.load(); 

回答

0

您没有设置代理,我应该是这样的:

var mystore = new Ext.data.Store({ 
    fields: [{ 
     name: 'title', 
     type: 'string', 
     mapping: 'title' 
    }], 
    proxy: { 
     type: 'ajax', 
     url: 'http://weather.yahooapis.com/forecastrss?w=2121267&u=c.xml', 
     reader: { 
      type: 'xml', 
      record: 'channel' 
     } 
    } 
}); 

mystore.load(); 

但我想你会遇到一个跨域问题,所以使用JSON-P API,并在你的商店设置一个JSON-P代理。

+0

谢谢,我知道了,现在我有:XMLHttpRequest无法加载http://weather.yahooapis.com/forecastrss?w=2121267&u=c&_dc=1366539116942&page=1&start=0&limit=25。 Access-Control-Allow-Origin不允许源http:// localhost:1715。 (( – 2013-04-21 10:13:55

+0

非常感谢,师父! – 2013-04-21 10:19:56

+0

http://jsfiddle.net/q43db/ – 2013-04-21 10:21:07