Skip to content

Commit

Permalink
treat status=0 as Ajax error unless over "file:" protocol
Browse files Browse the repository at this point in the history
Closes #283
  • Loading branch information
mislav committed Nov 3, 2011
1 parent 9a4be0d commit 75a759d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ajax.js
Expand Up @@ -228,6 +228,7 @@

var mime = settings.accepts[settings.dataType],
baseHeaders = { },
protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
xhr = $.ajaxSettings.xhr(), abortTimeout;

if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest';
Expand All @@ -238,7 +239,7 @@
if (xhr.readyState == 4) {
clearTimeout(abortTimeout);
var result, error = false;
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 0) {
if ((xhr.status >= 200 && xhr.status < 300) || (xhr.status == 0 && protocol == 'file:')) {
if (mime == 'application/json' && !(/^\s*$/.test(xhr.responseText))) {
try { result = JSON.parse(xhr.responseText); }
catch (e) { error = e; }
Expand Down

0 comments on commit 75a759d

Please sign in to comment.