+ 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();
xhr.onloadstart = function(e) {
xhr.onloadstart = function (e) {
loading.removeClass("hide");
$('.sidenav').sidenav('close');
loading.modal('open');
};
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
if(xhr.responseText != null) {
loading.modal('close');
xhr.onloadend = function (e) {
clearSelected();
if (/[a-z]/.test(xhr.responseText)) {
console.log(xhr.responseText);
loading.modal('close');
$('#error-message').text(xhr.responseText);
error.modal('open');
}
}
}
xhr.onloadend = function (e) {
clearSelected();
updateDatasets();
form.reset();
};
xhr.open('POST', form.getAttribute('action'), true);

View File

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