Sencha touch 2 在Sencha Touch 2中使用XMLStore将RSS提要作为列表
我正在尝试将提要显示为列表。当我尝试将读卡器类型设置为json时,效果很好。但是,如果类型为xml,则它不起作用。我得到一个例外: 解释为脚本但使用MIME类型text/xml传输的资源:http://feeds.feedburner.com/TechCrunch/?_dc=1345109660600&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1".*Sencha touch 2 在Sencha Touch 2中使用XMLStore将RSS提要作为列表,sencha-touch-2,Sencha Touch 2,我正在尝试将提要显示为列表。当我尝试将读卡器类型设置为json时,效果很好。但是,如果类型为xml,则它不起作用。我得到一个例外: 解释为脚本但使用MIME类型text/xml传输的资源:http://feeds.feedburner.com/TechCrunch/?_dc=1345109660600&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1".* *未捕获的语法错误:意外的标记我认为您无法将XML读取为JSONP。看看
*未捕获的语法错误:意外的标记我认为您无法将XML读取为JSONP。看看JSONP是如何工作的: 同源策略防止任何浏览器从不同的URL加载数据。为了解决这个问题,可以向DOM添加一个-Tag,其中src属性包含要加载的数据的URL
但是在这之后,您就有了这个新脚本标记的开始和结束之间的数据(在您的例子中是RSS提要数据)。浏览器开始将其解释为JavaScript和-bam!意外标记您使用代理类型jsonp,因此它必须期望json作为响应,这就是您出错的原因。即使您想使用xml,也可以尝试读卡器类型ajax。感谢您的响应。但是,代理类型可以是:Ajax(向同一域上的服务器发送请求)或JsonP(根据我的说法,向不同域上的服务器发送请求)。那么,这里还有什么不对劲的地方吗?
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'
]
}});
http://ajax.googleapis.com/ajax/services/feed/load?q=URL&v=1.0&num=10&output=json-in-script