This commit is contained in:
Aevann1 2021-12-17 06:44:25 +02:00
parent 2e81f2abd7
commit 822d841251
16 changed files with 30 additions and 47 deletions

View file

@ -15,33 +15,24 @@ function post_toast2(url, button1, button2) {
xhr.withCredentials=true;
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && !data["error"] ) {
try {
document.getElementById('toast-post-success-text').innerText = JSON.parse(xhr.response)["message"];
} catch(e) {
document.getElementById('toast-post-success-text').innerText = "Action successful!";
}
document.getElementById('toast-post-success-text').innerText = data["message"];
} catch(e) {}
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
myToast.show();
return true
} else if (xhr.status >= 300 && xhr.status < 400) {
window.location.href = JSON.parse(xhr.response)["redirect"]
window.location.href = data["redirect"]
} else {
try {
data=JSON.parse(xhr.response);
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show();
document.getElementById('toast-post-error-text').innerText = data["error"];
return false
} catch(e) {
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
myToast.hide();
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show();
return false
}
} catch(e) {}
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show();
return false
}
};