dsfsfd
This commit is contained in:
parent
2e81f2abd7
commit
822d841251
16 changed files with 30 additions and 47 deletions
|
@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue