+ now correctly working error messages

Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
Johannes Theiner 2019-06-05 17:33:55 +02:00
parent 4068239070
commit e0bfd8826f
2 changed files with 17 additions and 20 deletions

View File

@ -17,27 +17,23 @@ form.onsubmit = function (event) {
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
xhr.onloadstart = function(e) { xhr.onloadstart = function (e) {
loading.removeClass("hide"); loading.removeClass("hide");
$('.sidenav').sidenav('close'); $('.sidenav').sidenav('close');
loading.modal('open'); loading.modal('open');
}; };
xhr.onreadystatechange = function() { xhr.onloadend = function (e) {
if (xhr.readyState == XMLHttpRequest.DONE) { clearSelected();
if(xhr.responseText != null) { if (/[a-z]/.test(xhr.responseText)) {
loading.modal('close');
console.log(xhr.responseText); console.log(xhr.responseText);
loading.modal('close');
$('#error-message').text(xhr.responseText); $('#error-message').text(xhr.responseText);
error.modal('open'); error.modal('open');
} }
}
}
xhr.onloadend = function (e) {
clearSelected();
updateDatasets(); updateDatasets();
form.reset(); form.reset();
}; };
xhr.open('POST', form.getAttribute('action'), true); xhr.open('POST', form.getAttribute('action'), true);

View File

@ -144,16 +144,17 @@
<div class="modal-footer"> <div class="modal-footer">
</div> </div>
</div>
<div id="error" class="modal"> <div id="error" class="modal">
<div class="modal-content"> <div class="modal-content">
<h4>Es ist ein Fehler aufgetreten</h4> <i class="material-icons">error_outline</i>
<p id="error-message">A bunch of text</p> <h2 class="center">Fehler</h2>
<h4 id="error-message" class="center">Hallo Welt, das sollte nie zu sehen sein.</h4>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Ok</a> <a href="#!" class="modal-close waves-effect waves-green btn-flat">Ok</a>
</div> </div>
</div>
</div> </div>