Преглед на файлове

Add error handling for HTTP response codes other than 200.

This works also for local errors such as no connection as browsers
return a response code of 0 in that case
image-upload-drag
Michael Demetriou преди 4 години
родител
ревизия
be93f91311
променени са 1 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. +9
    -1
      templates/pad.tmpl

+ 9
- 1
templates/pad.tmpl Целия файл

@@ -434,7 +434,11 @@
xhr.send(formData);
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
processResponse(xhr.responseText, file.identifier);
if (xhr.status == 200){
processResponse(xhr.responseText, file.identifier);
} else {
processFailure(file.identifier);
}
}
}
}
@@ -445,6 +449,10 @@
textarea.value = textarea.value.replace(getMarkdownRegex(identifier), "["+ description +"]("+response.url+")");
}

function processFailure(identifier){
textarea.value = textarea.value.replace(getMarkdownRegex(identifier), "");
}

function getMarkdownRegex(identifier){
return new RegExp('\\[' + identifier + '\\]\\(.*?\\)');
}


Зареждане…
Отказ
Запис