You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
43 lines
1.6 KiB
$(document).ready(function() {
|
|
$('#btn_first_confirm').click(function() {
|
|
$.ajax({
|
|
url: 'verify_otp/generate_otp', // URL du contrôleur
|
|
type: 'POST',
|
|
data: {
|
|
'csrf_token': $('meta[name="csrf_token"]').attr('content') // Récupérer le token CSRF actuel
|
|
},
|
|
dataType: 'json', // Format attendu
|
|
success: function(response) {
|
|
// Mettre à jour le token CSRF dans la balise <meta> si reçu
|
|
if (response.csrf_token) {
|
|
$('meta[name="csrf_token"]').attr('content', response.csrf_token);
|
|
}
|
|
|
|
if (response.success) {
|
|
// Affiche la notification de succès
|
|
notify(response.message, "success");
|
|
|
|
// Redirection après 2 secondes
|
|
setTimeout(function() {
|
|
window.location.href = response.redirect_url;
|
|
}, 1000);
|
|
} else {
|
|
// Affiche un message d'erreur reçu du contrôleur
|
|
notify(response.message, "error");
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Affiche une erreur générique en cas d'échec de la requête
|
|
notify('Erreur lors de la génération de l\'OTP : ' + error, "error");
|
|
}
|
|
});
|
|
});
|
|
|
|
// Fonction de notification
|
|
function notify(message, type) {
|
|
$.notify(message, {
|
|
className: type,
|
|
position: "top right"
|
|
});
|
|
}
|
|
});
|
|
|