Skip to content

Commit b79e539

Browse files
修复302重定向跳转 404 效果错误 review by luox
1 parent 6fb421d commit b79e539

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

examples/js/editor.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,27 @@ function loadExampleHtml() {
9696
return;
9797
}
9898
var isError = false;
99-
var html = $.ajax({
99+
var notFoundPath = '/web/404.html';
100+
var response = $.ajax({
100101
url: mapUrl,
101102
async: false,
102103
error: function (error) {
103104
alert(resources.editor.envTips);
104105
isError = true;
105106
}
106-
}).responseText;
107+
});
108+
if (response && response.status === 302) {
109+
var location = response.getResponseHeader('Location');
110+
if (location && location.indexOf(notFoundPath) !== -1) {
111+
isError = true;
112+
}
113+
}
114+
var html = response.responseText;
107115
if (html && html != "" && !isError) {
108116
$('#editor').val(html);
109117
loadPreview(html);
110118
} else {
111-
window.location.href = window.location.origin + '/web/404.html';
119+
window.location.href = window.location.origin + notFoundPath;
112120
}
113121
}
114122

0 commit comments

Comments
 (0)