This commit is contained in:
Aevann1 2021-12-31 17:17:13 +02:00
parent c5af36ad2e
commit e88971dd3e
7 changed files with 32 additions and 44 deletions

View file

@ -26,21 +26,15 @@ function post_toast(url, reload, data) {
xhr.withCredentials=true;
xhr.onload = function() {
try {
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && !data['error']) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
} else {
if (data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
if (reload == 1) {location.reload(true)}
} else {
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
catch(e) {new bootstrap.Toast(document.getElementById('toast-post-error')).show();}
};
xhr.send(form);