View Full Version : HTTP status of 0 prevents json from loading in phonegap

4 Sep 2011, 11:03 AM
When loading json locally (file://) or in phonegap, the http status in xhdr is zero. The sencha js interprets this as an error an fires an exception event rather than accepting the data and calling the store.load callback.

Note: In Adobe Flash, when loading xml locally, I also get a zero http status code, but flash still fires the 'complete' event and everything works fine.

Here is my work around: In the function Ext.data.Connection.onComplete, I've changed the first if statement to:

if ((status >= 200 && status < 300) || status == 304 ||
(status == 0 && r.xhr.responseText.length > 0) ) {

There might be a better way to do this, but it seems to work for me.

Joel May

Edit: Sorry I did not follow the proper format. I neglected to read the rules before I posted this.
Anyway, I see this is an iphone/ipad universal phonegap app. I'm using the most recent versions of sencha-touch and phonegap. I am seeing this behavior in the simulator. I also see it in the safari desktop browser when NOT running in localhost (i.e. file://). I have not tested on the actual device yet, but I expect it to be a problem there also.

23 Sep 2011, 3:36 AM

is there any new information available regarding this topic?

I had the same problem and joelmay's fix worked fine for me (thanks for posting)...


28 Nov 2011, 8:54 PM

to all who have a problem using their offline json in Sencha/Phonegap/Android environment -- this definitely solved that problem.=D>

tnx guys.

7 Feb 2012, 1:05 PM
I've confirmed this is necessary with Sencha Touch 2 as well. To fix, I changed Connection.js, line 755, from:

result = me.parseStatus(request.xhr.status);


if (request.xhr.status == 0 && request.xhr.responseText.length > 0) {
result = {success: true, isException: false}
} else {
result = me.parseStatus(request.xhr.status);