Commit 35f839be authored by hbcui1984's avatar hbcui1984

Fix:本地路径不存在时,mui.ajax()方法依然触发成功回调的bug;

parent 92089556
......@@ -162,7 +162,8 @@
xhr.onreadystatechange = $.noop;
clearTimeout(abortTimeout);
var result, error = false;
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && protocol === 'file:')) {
var isLocal = protocol === 'file:';
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && isLocal && xhr.responseText)) {
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'));
result = xhr.responseText;
try {
......@@ -184,7 +185,13 @@
ajaxSuccess(result, xhr, settings);
}
} else {
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings);
var status = xhr.status ? 'error' : 'abort';
var statusText = xhr.statusText || null;
if (isLocal) {
status = 'error';
statusText = '404';
}
ajaxError(statusText, status, xhr, settings);
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment