我正试图将提要显示为列表。当我尝试使用读取器类型为json时,它工作得很好。但是,如果类型为xml,则不起作用。我有个例外:
资源被解释为脚本,但使用MIME类型text/xml传输:"* *Uncaught :意外令牌<
Ext.define('TestViews.view.RSSFeedView', {
requires:[
'TestViews.view.CommonTitleBar',
'TestViews.view.CommonContainer',
'TestViews.locale.MsgResource'
],
extend: 'Ext.Panel',
xtype: 'Test-rssfeedview',
id:'rssFeedView',
config: {
fullscreen: true,
layout: {
type: 'vbox'
},
autoDestroy: true,
items: [
{
xtype: 'Test-commontitlebar',
title: 'RSS Feed Component'
},
{
xtype: 'list',
id: 'rssFeedList',
title : 'RSS Feed View',
itemId:"testList",
onItemDisclosure: true,
itemTpl: '{title}',
flex: 1,
store:{
model: "TestViews.model.RSSFeedViewModel",
autoLoad: true,
implicitIncludes: true,
proxy: {
type: 'jsonp',
url: 'http://feeds.feedburner.com/TechCrunch/',
reader: {
type: 'xml',
root: 'channel',
record: 'channel'
}
}
},
width: '100%',
autoDestroy: true,
}
]
}
})型号:
enter Ext.define('TestViews.model.RSSFeedViewModel', {
extend: 'Ext.data.Model',
config: {
fields: [
'title','description'
]
}});你能告诉我我在这里做错了什么吗?
发布于 2012-12-17 14:14:12
我认为您不能将XML理解为JSONP。看看JSONP是如何工作的:
“相同的源策略”禁止任何浏览器从不同的URLS加载数据。要解决这个问题,您可以使用src属性向DOM添加一个-Tag,其中包含要加载的数据的URL。
但是之后,在这个新脚本标记的开始和结束之间有数据(在您的例子中是RSS提要数据)。浏览器开始将其解释为JavaScript和- bam!意外标记< ..。这是正确的,因为它不是JavaScript,而是RSS。
摘要:JSONP只用于从另一个URL!加载JavaScript
解决方案:您可以将RSS数据包装为JSON中的字符串。Google在这里帮助您:
http://ajax.googleapis.com/ajax/services/feed/load?q=URL&v=1.0&num=10&output=json-in-script这为您提供了一个包含转换后的提要数据的JSON对象。搜索API文档中的参数,这才是真正的帮助您。
学分:http://www.alaafu.com/rssreader-sencha/#favorites/first
https://stackoverflow.com/questions/11984654
复制相似问题