Sencha Touch JSONP Error

EDIT:

I came across a confirmation of what I suspected: using the twitter search API with JSONP causes the problem in isolation, so it seems like something is wrong with Twitter.

See: http://search.twitter.com/search.json?q=%23jimromeisburning&callback=dog

About 3/5 times, as of 3:44 p.m. CT on June 14, Twitter returns the trash. The rest of the time it returns a valid javascript function call.


I use Sencha Touch to make a JSONP request to the Twitter search API, and about 1/100 times, I get a javascript error that kills a further poll:

Uncaught SyntaxError: Unexpected token ILLEGAL 

So far I have tried the following without any indication:

  • Ending a call in Ext.util.JSONP.request ({}) in a try / catch block. Does not catch the error (presumably because it is called from the script tag in the iframe)
  • Discarding the query parameter passed to JSONP.request to make sure it is valid. It.
  • Pattern search - it seems to happen in unexpected times. It may be the very first request, or it may be 100 requests per line.

My best guess is that Twitter sometimes sends trash. This is normal, I just need a way to handle this error. Unfortunately, as far as I can tell, Sencha Touch does not have built-in error handling for its JSONP requests.

Have you seen anything like this before? Do you have any ideas?

Thanks!

Here is what the orsery JSONP script answer looks like:

 Ext.util.JSONP.callback( Řo 6ǿ  `)֥  k em  + `  - -  RT  w ɖ   $v -A^ґ   Ow | 4Tua*+    ת    Ⱥ  VbšҐ ֡5Ҫ/芒 [ o ƌ  NnjE9褪   *  N3 1j;QRǏ®T  E r4  S  @  w|  !a.   ġ %     @  *    >Z8^_h  녾z>u] E  ϸ V  u k&#@k )Hc}=   ;o% .  ׍   L  5 T B* ?      {   ꒼z M   .}/dm =   곒5i KA  y    Q n   n     Һ x  ̼R N   q k  < \+s *   &[  DCњH WE Ƴ   uhj ڼ    ȋ  ,t" > '    o VnK  ⳍ \ p,'9    :~{  "   8n   x ͫK   C mx( <      3>      B]A_ L += %fY *1  /   wO vc Z8d=)̦1    ߳35    -F    .f   D| .z6    Xs  s\愶    M*Z D    7ڈ )ϗ cA ^9N n  aN@  w /^ P  ¸- E $R     < K n 3A3  򳀇 L+ mI  vՃ 0Ǎ}o   Q  4     =e  n q8  ģ     . C)s= :+> O h9 C2Q5Y   PA    * 3y1 t `   g  WǠ YB O / {+. [    ,ߴ  / yQ <t(G    ݾ b  ijBS 9  .E > D% I   jz 켻0 q  0`Q  .  . >88 춖  (i4fȻ gW@  aI*       #   z j \5g  \ n   e   c  7 o  w z , |/  + N     } z+v    nd  NY R  o   }  hĚ ;  g D2  9     :-e     ^@Ua   j2C  # U   k 9   I ' ܐ   /H3 q(  d < $    q5  }  V ft 'U'{   0     Ø  sC?|B  0I   B E] % c  S   6LC x Y EQT * Akr  ÷OyOn  N 7iSkW`  F q !     +,[   I  1  i 3C*    _  h K    ^ { V|YìM 7ŬW t  '  ek  y lr l WM)Đ > O   F,` w  r  6 a X    B n 2t O\ R7  O n   !` @ M  i   MU]5_ k TMR   'Z  Y  C Sn q. V  ";d `x  k Β  Mr  /     ٬A  Fq B|L   >+,B0  R  K     ˵u _~縫}  Zw    E   7 K    :. i n%  4l /F         5_     ); 
+4
source share
2 answers

I recently answered a similar question in which the OP encountered unsuccessful whales when using the search API.

I found this question in which there were some interesting answers regarding error handling in JSONP. To summarize, one approach is to wrap all errors returned by the server in JSON, and the other provides a jQuery-JSONP link , a nice looking reinterpretation of the jQuery JSONP implementation.

+1
source

Interesting. You will need to override the callback method in the Ext.util.JSONP class and wrap the string that calls the callback in a try / catch block. Then, in the catch block, try calling errorCallback (which you need to define in your actual JSONP request).

 Ext.util.JSONP.callback = function(json) { try { this.current.callback.call(this.current.scope, json); } catch(e) { this.current.errorCallback.call(this.current.scope); } document.getElementsByTagName('head')[0].removeChild(this.current.script); this.next(); }; 
+1
source

All Articles