我有一个应用程序正在从外部Web服务中使用JSONP的面板。无法使用scripttag代理和JSONP在Sencha Touch中获取Data Store
型号/ VimeoModel.js
rpc.models.VimeoModel = Ext.regModel('rpc.models.VimeoModel', {
fields: [
{name: 'id', type: 'int'},
{name: 'title', type: 'string'}
]
});
的意见/ VideoView.js
rpc.views.VideoView = new Ext.Panel({
id: 'VideoView',
title: "Videos",
tpl: VimeoTemplate,
iconCls: "tv",
dockedItems: [{ xtype: "toolbar", title: "Videos"}],
store: 'rpc.stores.VimeoStore'
});
店/ VimeoStore.js
rpc.stores.VimeoStore = new Ext.data.Store({
id: 'VimeoStore',
model: 'rpc.models.VimeoModel',
proxy: {
type: 'scripttag',
url: WebService.Url + WebService.Vimeo.Read,
reader: {
type: 'jsonp',
root: 'results'
}
},
autoLoad: true
});
个模板/ VimeoTemplate.js
var VimeoTemplate = new Ext.XTemplate([
'<tpl for=".">',
'<div>',
'{title}',
'</div>',
'</tpl>'
]);
不幸的是在页面加载时,没有数据被填充到VideoView。
WebService的请求是这样的
http://rpc.infinitas.ws/Vimeo/Read?_dc=1308067234445&limit=25&callback=stcCallback1001
它返回了JSONP响应
stcCallback1001({"results":[{"id":25036464,"title":"Power of A Surrendered Li..."},{"id":25036610,"title":"Child Dedication June 2011"},{"id":24734142,"title":"Power of A Surrendered Li..."},{"id":24884833,"title":"Finance Update June 2011"},{"id":24587711,"title":"Papua, Indonesia Sharing ..."},{"id":24232427,"title":"ICHTHUS: Coming King"},{"id":23868560,"title":"ICHTHUS: Healer"},{"id":23486615,"title":"ICHTHUS: Sanctifier"},{"id":23211649,"title":"ICHTHUS: Saviour"},{"id":23867961,"title":"Elder Announcement re: Br..."},{"id":22998163,"title":"Triumph of Grace: Risen L..."},{"id":23687914,"title":"Triumph of Grace: Reignin..."},{"id":23692076,"title":"KINGDOM now: For Thine Is..."},{"id":23694183,"title":"KINGDOM now: Deliver Us F..."}],"success":true});stcCallback1001({"results":[{"id":25036464,"title":"Power of A Surrendered Li..."},{"id":25036610,"title":"Child Dedication June 2011"},{"id":24734142,"title":"Power of A Surrendered Li..."},{"id":24884833,"title":"Finance Update June 2011"},{"id":24587711,"title":"Papua, Indonesia Sharing ..."},{"id":24232427,"title":"ICHTHUS: Coming King"},{"id":23868560,"title":"ICHTHUS: Healer"},{"id":23486615,"title":"ICHTHUS: Sanctifier"},{"id":23211649,"title":"ICHTHUS: Saviour"},{"id":23867961,"title":"Elder Announcement re: Br..."},{"id":22998163,"title":"Triumph of Grace: Risen L..."},{"id":23687914,"title":"Triumph of Grace: Reignin..."},{"id":23692076,"title":"KINGDOM now: For Thine Is..."},{"id":23694183,"title":"KINGDOM now: Deliver Us F..."}],"success":true});
当我火了Chrome的JavaScript控制台我得到一个错误
Read:1 Uncaught ReferenceError:stcCallback1001 is not defined
而这里的如果您需要更多信息,请登台应用程序
http://rpcm.infinitas.ws
感谢您的回复,我尝试了您的建议,并更新了我的问题,以求清晰。不幸的是我仍然陷入困境。 – 2011-06-14 02:01:37
对不起,我认为这是一个随机数,事实证明它始终是'stcCallback1001' - 我会再次编辑我的问题。 – 2011-06-14 03:05:11
如果我向代理添加'callbackParam:'idSession'',那么“未定义”错误消失,但是相反,我得到“TypeError:数字不是函数”。 – 2011-06-14 03:26:53