fd
This commit is contained in:
parent
c816663ecc
commit
8728b664b6
1 changed files with 26 additions and 27 deletions
|
@ -277,37 +277,36 @@ function post_toast(url, callback, data) {
|
||||||
xhr.withCredentials=true;
|
xhr.withCredentials=true;
|
||||||
|
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
if (xhr.status==204) {}
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
else if (xhr.status >= 200 && xhr.status < 300) {
|
$('#toast-post-success').toast('dispose');
|
||||||
|
$('#toast-post-success').toast('show');
|
||||||
|
document.getElementById('toast-post-success-text').innerText = "Action successful!";
|
||||||
|
callback(xhr)
|
||||||
|
return true
|
||||||
|
|
||||||
|
} else if (xhr.status >= 300 && xhr.status < 400) {
|
||||||
|
window.location.href = JSON.parse(xhr.response)["redirect"]
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
data=JSON.parse(xhr.response);
|
||||||
|
|
||||||
|
$('#toast-post-error').toast('dispose');
|
||||||
|
$('#toast-post-error').toast('show');
|
||||||
|
document.getElementById('toast-post-error-text').innerText = data["error"];
|
||||||
|
return false
|
||||||
|
} catch(e) {
|
||||||
$('#toast-post-success').toast('dispose');
|
$('#toast-post-success').toast('dispose');
|
||||||
$('#toast-post-success').toast('show');
|
$('#toast-post-error').toast('dispose');
|
||||||
document.getElementById('toast-post-success-text').innerText = "Action successful!";
|
$('#toast-post-error').toast('show');
|
||||||
callback(xhr)
|
document.getElementById('toast-post-error-text').innerText = "Error. Try again later.";
|
||||||
return true
|
return false
|
||||||
|
|
||||||
} else if (xhr.status >= 300 && xhr.status < 400) {
|
|
||||||
window.location.href = JSON.parse(xhr.response)["redirect"]
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
data=JSON.parse(xhr.response);
|
|
||||||
|
|
||||||
$('#toast-post-error').toast('dispose');
|
|
||||||
$('#toast-post-error').toast('show');
|
|
||||||
document.getElementById('toast-post-error-text').innerText = data["error"];
|
|
||||||
return false
|
|
||||||
} catch(e) {
|
|
||||||
$('#toast-post-success').toast('dispose');
|
|
||||||
$('#toast-post-error').toast('dispose');
|
|
||||||
$('#toast-post-error').toast('show');
|
|
||||||
document.getElementById('toast-post-error-text').innerText = "Error. Try again later.";
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
xhr.send(form);
|
xhr.send(form);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Search Icon
|
// Search Icon
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue