PDA

View Full Version : about Ext.util.JSONP.request



lokinfey
25 Oct 2010, 5:29 AM
I use Ext.util.JSONP.request. but it can not load my json data ! can u help me :-/
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function() {
var timeline = new Ext.Component({
title: '课程学习',
cls: 'timeline',
scroll: 'vertical',
tpl: [
'<tpl for=".">',
'<div>',
'<div><img src="{MobileImg}" /></div>',
'<div>',
'<h2>{Len}</h2>',
'<p>{Video}</p>',
'</div>',
'</div>',
'</tpl>'
]
});
var panel = new Ext.TabPanel({
fullscreen: true,
animation: 'slide',
items: [timeline]
});
var refresh = function() {
alert('hello');
Ext.util.JSONP.request({
url: 'http://course.gdou.com/gxk/Home/GetVideoAll',
callbackKey: 'callback',
callback: function(result) {
timeline.update(result);
}
});
};
var tabBar = panel.getTabBar();
tabBar.addDocked({
xtype: 'button',
ui: 'mask',
iconCls: 'refresh',
dock: 'right',
stretch: false,
align: 'right',
handler: refresh
});
}

kientran
25 Oct 2010, 7:51 AM
Quick test shows that it is not returning the data in a JSONP format. JSONP requires that your server returns the data wrapped in a function by the name of callback parameter. See the JSONP library Sencha documents for some server code examples.

The server should return something along the lines of Ext.util.JSONP.callback( {yourdata} );