View Full Version : JSONP chaining static calls - is this a bug or a feature?

20 Jul 2011, 7:54 AM
had a look through the forums and now looking at the src code and can't find anything about this but i'm a little confused as to the implementation of the Ext.util.JSONP.request method.

ok - you may have to bear with me a little here...
what i'm trying to do is run a jsonp call and then in the result of that callback i make another call to something else. I've ripped this out of my application and put together a standalone example.

here is my code.

run = function() {

callMeBackOne = function(data) {
//Ext.util.JSONP.current = null;

callMeBackTwo = function(data) {

assume the response data/t1.jsonp returns simply a call

and data/t2.jsonp returns


now when you call the run() method it:-

executes the call to t1.jsonp,
then calls the next jsonp call to t2.json

then nothing happens...
because in the implementation of Ext.util.JSONP there is a check to see if this is the current request in the static init. from senchatouch code 1.1.0

if (!this.current) {
this.next(); //effectively make the call

now the this.next is never reset unless the Ext.util.JSONP.callback method is called (which call next() and sets it to null) so you won't be able to execute another JSONP call if you are manually managing your callbacks.

however if uncomment //Ext.util.JSONP.current = null; then both my calls works fine.

i couldn't think of a situation you'd want to prevent a call - possible infinite loops but it seems unlikely and that is more of a problem for bad code design rather than catching in the framework - is this a bug or a feature?
perhaps i've completely missed something here?
does anyone have any experience of effectively chaining JSONP calls?

15 Aug 2011, 10:59 AM
I'm having the same issue. I'm trying to call Ext.util.JSONP in a loop, and with the JSONP code each URL is properly being added to its internal queue. However, "current" isn't being reset, so only the first URL ever gets run. Am I using it wrong? Or is this a bug?

16 Aug 2011, 6:25 AM
PulpMysteryFan - i posted it in 'bugs' as well but nobody every replied to it...


no help - so at the moment i'm manually setting

Ext.util.JSONP.current = null;
when i know that my callback code has executed :-S
no doubt this will break when a new release comes out

16 Aug 2011, 6:46 AM
I'm doing several calls in a tight loop. Each iteration calls Ext.util.JSONP.request(). After each call I'm setting current to null (and it's working -- at least for my situation). That may be breaking something since the programmer who wrote Ext.util.JSONP had something in mind by using the queue and current. But I'll wait to see if Sencha responds before doing any more digging...