Files
Inventario_material_v1/js/main.js
T
2019-01-15 20:28:24 -06:00

44 lines
1.2 KiB
JavaScript

jQuery(document).on('submit','#formlg',function(event){
event.preventDefault();
jQuery.ajax({
url: 'login.php',
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
beforeSend: function() {
$('.botonlg').val('Validando...');
}
})
.done(function (respuesta) {
console.log(respuesta);
if (!respuesta.error){
if (respuesta.perfil == 'Jefatura')
{
location.href = 'sitio/admin/admin.php';
}
else if (respuesta.perfil == 'Area')
{
console.log("Area");
location.href = 'sitio/usuario/usuario.php';
}
}
else{
$('.error').slideDown('slow');
setTimeout(function () {
$('.error').slideUp('slow')
},3000);
$('.botonlg').val('Iniciar Sesion');
}
})
.fail(function (resp) {
console.log(resp.responseText);
})
.always(function(){
console.log("complete");
});
});