diff --git a/src/app/static-resources/static/js/home.js b/src/app/static-resources/static/js/home.js index e0838023..ee9dac0a 100644 --- a/src/app/static-resources/static/js/home.js +++ b/src/app/static-resources/static/js/home.js @@ -141,15 +141,21 @@ function post(url, params, sendingButton) { if(data.redirect_to) { window.location.replace(data.redirect_to); } + if(data.error) { + showErrorMessage(sendingButton, data.error); + } }) .catch(error => { console.error(error); resetButton(sendingButton); - const errorElement = htmlStringToElement('

Er is iets misgegaan. Probeer het opnieuw.

'); - sendingButton.parentElement.appendChild(errorElement); + showErrorMessage(sendingButton, 'Er is iets misgegaan.'); }); } addFormEventHandlers(); addCopyToClipboardButtons(); +function showErrorMessage(besidesElement, error) { + const errorElement = htmlStringToElement(`

${error}

`); + besidesElement.parentElement.appendChild(errorElement); +}