View Full Version : How to trigger the callback function of Ext.util.JSONP.request by jsp

18 Jul 2011, 11:04 PM
Hi all,
I want to send a JSONP request to a jsp page and get json data for my app ,with code as follows:

onReady: function() {
var makeJSONPRequest = function() {
//Ext.getBody().mask('Loading...', 'x-mask-loading', false);
//url: 'http://www.worldweatheronline.com/feed/weather.ashx',
callbackKey: 'callback',
params: {
//key: '23f6a0ab24185952101705',
// palo alto
//q: '94301',
format: 'json'
//num_of_days: 5

callback: function(result) {
var func1 = function(){

new Ext.Panel({
fullscreen: true,
id: 'content',
scroll: 'vertical',
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
text: 'TEST JSON',
handler: makeJSONPRequest
},{xtype: 'spacer'},{
text: 'XMLHTTP',
handler: func1
id: 'status',
xtype: 'toolbar',
dock: 'bottom',
title: "Tap a button above."
however ,callback: function(result) won't be called. My jsp can be visited in a browser:
and I made it to have exactly same content with the following page: http://www.worldweatheronline.com/feed/weather.ashx?key=23f6a0ab24185952101705&q=94301&format=json&num_of_days=5
however ,the latter page can trigger Ext.util.JSONP.callback() but the former one won't.
In sencha touch examples talks only about php examples, and I cannot find jsp examples, who could help me to figure out the problem or give me an example? With great thx!

19 Jul 2011, 12:57 AM
OK?problem has been solved ?wrap the json string with Ext.util.JSONP.callback (); that is : Ext.util.JSONP.callback ({...}); then the callback: function(result) will be called ,thx to all!