From e0bfd8826fa7c2fb5e18e1e228fea259be2b0a5b Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Wed, 5 Jun 2019 17:33:55 +0200 Subject: [PATCH] + now correctly working error messages Signed-off-by: Johannes Theiner --- src/main/webapp/js/upload.js | 20 ++++++++------------ src/main/webapp/menu.jsp | 17 +++++++++-------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/webapp/js/upload.js b/src/main/webapp/js/upload.js index 5c187d0..635c698 100644 --- a/src/main/webapp/js/upload.js +++ b/src/main/webapp/js/upload.js @@ -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'); - console.log(xhr.responseText); - $('#error-message').text(xhr.responseText); - error.modal('open'); - } - } - } - 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'); + } updateDatasets(); form.reset(); + }; xhr.open('POST', form.getAttribute('action'), true); diff --git a/src/main/webapp/menu.jsp b/src/main/webapp/menu.jsp index 9b7d49f..b4b56f1 100644 --- a/src/main/webapp/menu.jsp +++ b/src/main/webapp/menu.jsp @@ -144,15 +144,16 @@ + -