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?