Ich muss eine Ajax-Funktion ausführen, nachdem Bestätigung auf einem Bootbox-Bestätigungsmodal gedrückt wird. Das Modal blinkt kurz, dann wird der PHP-Code ohne Warten ausgeführt. Wie kann ich warten?Warten auf Bootbox Bestätigen, um Ajax auszuführen
Meine Javascript ausgeführt wird, wenn entferne ich die Bootbox aber ich möchte, um zu bestätigen, bevor es Ihr Code
laufen gelassen ist,
$('#change_pass_form').submit(function() {
bootbox.confirm({
message: "Your password is about to be changed. Are you sure?",
buttons: {
cancel: {label: '<i class="fa fa-times"></i> Cancel'},
confirm: {label: '<i class="fa fa-check"></i> Confirm'}
},
callback: function (result) {
if (result === 'true') {
$.ajax({
type: 'POST',
url: 'php_files/profile_php_files/profile_password_change_process.php',
data: {
user_id: sessionStorage.getItem('user_id'),
new_password: $('#new_password').val(),
repeat_password: $('#repeat_password').val()
},
success: function (data) {
if (data === 'correct') {
bootbox.alert({
size: 'small',
message: 'Your password has been changed. You will now be logged out.',
callback: function() {
window.location.replace('index.html');
}
});
return true;
} else {
bootbox.alert({
size: 'small',
message: data
});
return false;
}
}
});
} else {
return false;
}
}
});
});
perfekt gearbeitet. Vielen Dank – Drewy