{"id":1439,"date":"2022-08-30T15:16:32","date_gmt":"2022-08-30T15:16:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/16\/sencha-touch-jsonp-error-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:32","modified_gmt":"2022-08-30T15:16:32","slug":"sencha-touch-jsonp-error-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/sencha-touch-jsonp-error-collection-of-common-programming-errors\/","title":{"rendered":"Sencha Touch JSONP error-Collection of common programming errors"},"content":{"rendered":"<p>EDIT:<\/p>\n<p>I came across a confirmation of what I suspected: Using the twitter search API with JSONP causes the problem in isolation, so it seems that something is going wrong with Twitter.<\/p>\n<p>See: http:\/\/search.twitter.com\/search.json?q=%23jimromeisburning&amp;callback=dog<\/p>\n<p>About 3\/5 times, as of 3:44PM CT on 14 June, Twitter returns garbage. The rest of the time, it returns a valid javascript function call.<\/p>\n<p>I&#8217;m using Sencha Touch to make a JSONP request to the Twitter search API, and about 1\/100 times, I&#8217;m getting a javascript error that kills further polling:<\/p>\n<pre><code>Uncaught SyntaxError: Unexpected token ILLEGAL\n<\/code><\/pre>\n<p>So far I&#8217;ve tried the following with no leads:<\/p>\n<ol>\n<li>Wrapping the call to Ext.util.JSONP.request({}) in a try\/catch block. Doesn&#8217;t catch the error (presumably because it&#8217;s being called from a script tag in an iframe)<\/li>\n<li>Dumping the <code>query<\/code> parameter passed into JSONP.request to make sure that it&#8217;s valid. It is.<\/li>\n<li>Looking for a pattern&#8211; it seems to happen at unexpected times. Could be the very first request, or it could be 100 requests down the line.<\/li>\n<\/ol>\n<p>My best guess is that Twitter is sending back garbage some of the time. That&#8217;s ok, I just need a way to handle that error. Unfortunately, as far as I can tell, Sencha Touch doesn&#8217;t have any built-in error handling for its JSONP requests.<\/p>\n<p>Have you seen anything like this before? Do you have any ideas?<\/p>\n<p>Thanks!<\/p>\n<p>Here&#8217;s what the ornery JSONP script response looks like:<\/p>\n<pre><code>Ext.util.JSONP.callback(?Ro?6?\n?`)???k?em??+?`?\n-?-??RT??w?????$v?-A^????Ow?|?4Tua*+????????????Vbs???5?\/\n??[?o????N?E9????*??N3?1j;QRI\u00aeT??E?r4??S\n?@??w|??!a.???g?%?????@??*????&gt;Z8^_h???z&gt;u]?E????V??u?k&amp;#@k\n)Hc}=???;o%?.\n?????L??5?T?B*????????{????z?M???.}\/dm?=????5i?KA??y????Q?n???n????\n??x???R?N???q?k??<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-16 20:53:14. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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 that something is going wrong with Twitter. See: http:\/\/search.twitter.com\/search.json?q=%23jimromeisburning&amp;callback=dog About 3\/5 times, as of 3:44PM CT on 14 June, Twitter returns garbage. The rest of the time, it returns a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1439","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1439"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1439\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}