Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#10552 closed bug (invalid)

Ajax response status 0

Reported by: jonatan.wallgren@… Owned by: jonatan.wallgren@…
Priority: undecided Milestone: None
Component: unfiled Version:
Keywords: Cc:
Blocked by: Blocking:


Using jQuery.load can fail under some use cases even if the returned data is correct.

Consider following use case:

A webapp is served from a web server using ajax requests to fetch additional web pages using jquery load. All is fine.

Said webapp gets packaged with phonegap, now the resources will be fetched from the local file system on the device. On IOS, and possibly on other devices as well, the returned status code from the jQuery.load request will be zero even though the data in jqXHR.responseText will be returned correctly.

This documentation from Mozilla


states that XMLHttpRequest states "Despite its name, XMLHttpRequest can be used for non-HTTP requests." which I would guess a read from the local file system would be.

Also from the same document:

"The key thing to note here is that the result status is being compared to 0 for success instead of 200. This is because the file and ftp schemes do not use HTTP result codes."

Currently how you guys determine if the response is an error seems to be in this line of code:


"if ( status >= 200 && status < 300
status === 304 )"

Adding a passing condition for zero like this:

"if ( status >= 200 && status < 300
status === 304 status === 0)"

solves my immediate problem, I get my ajax request data back correctly. What do you guys think of adding this passing condition to the jQuery source? If this solution seems to be to fragile it could maybe be an idea introduce some ways of suppressing error code 0?

Change History (2)

comment:1 Changed 7 years ago by dmethvin

Owner: set to jonatan.wallgren@…
Status: newpending

Do you have a test case? What is the protocol you are using? Did you try setting isLocal? http://api.jquery.com/jQuery.ajax/

comment:2 Changed 7 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.