Files
NightSpire/home/static/nw-themes/nw-ryu/nw-js-handlers/change_password_response.js
T
2024-11-13 16:14:17 +01:00

44 lines
1.5 KiB
JavaScript

$(function(){
$('.change-password-button').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$("#change-password-response").empty();
var button = $(this);
var originalText = button.html();
var data = $("#nw-change-password-form").serialize();
changeButton(button, 'Cambiando contraseña');
$.ajax({
type: 'POST',
url: '',
data: data,
dataType: 'json',
success: function(response) {
$("#change-password-response").html(response.message).hide().slideDown();
if (response.success) {
button.html("Contraseña cambiada").css("color", "#d79602");
if (response.redirect) {
setTimeout(function() {
window.location.href = '/es/log-in';
}, 3000);
}
} else {
setTimeout(function() {
$("#change-password-response").slideUp(function() {
$("#change-password-response").empty();
restoreButton(button, originalText);
});
}, 5000);
}
},
error: function() {
alert("Algo ha salido mal. Por favor, intenta más tarde.");
window.location.reload();
}
});
});
});