catch json-parse error

pull/728/head
ruesin 6 years ago
parent 93f0d7a1ce
commit 1b50ce6015

@ -679,9 +679,13 @@ function uploadImage(editor) {
xmlhttp.send(formData); xmlhttp.send(formData);
xmlhttp.onreadystatechange = function() { xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var res = JSON.parse(xmlhttp.responseText); try {
if(res.url) { var res = JSON.parse(xmlhttp.responseText);
editor.codemirror.replaceSelection("![" + (res.name || file.name) + "](" + res.url + ")"); if(res.url) {
editor.codemirror.replaceSelection("![" + (res.name || file.name) + "](" + res.url + ")");
}
} catch (e) {
editor.codemirror.replaceSelection("![]()");
} }
} }
}; };

Loading…
Cancel
Save