Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $('form[name="form_login"]').submit(function () {
- var forma = $(this);
- var botao = $(this).find(':button');
- $.ajax({
- url: "ajax/controller.php",
- type: "POST",
- data: "acao=login&"+forma.serialize(),
- beforeSend: function(){
- botao.attr('disabled', true);
- $('.load').fadeIn('slow');
- },
- success: function(retorno){
- $('.load').fadeOut('slow', function (){
- botao.attr('disabled', false);
- });
- if(retorno === 'noif'){
- msg('Este login não é válido', 'erro');
- }else if(retorno === 'diffpass'){
- msg('Senha não confere com o login', 'alerta');
- }else if (retorno === 'non') {
- msg('Você não tem permissão para continuar com seu login!', 'info');
- }else{
- forma.fadeOut('fast', function(){
- msg('Login efetuado com sucesso, aguarde...', 'sucesso');
- $('#load').fadeIn('slow');
- });
- setTimeout(function(){
- $(location).attr('href', 'painel.php');
- }, 3000);
- }
- }
- });
- return false;
- });
- //FUNÇÕES GERAL
- function msg(msg, tipo){
- var retorno = $('.retorno');
- var tipo = (tipo === 'sucesso') ? 'success' : (tipo === 'alerta') ? 'warning' : (tipo === 'erro') ? 'danger' : (tipo === 'info') ? 'info' : alert('INFORME MENSAGENS DE SUCESSO, ALERTA, ERRO E INFO');
- retorno.empty().fadeOut('fast', function(){
- return $(this).html('<div class="alert alert-'+tipo+'">'+msg+'</div>').fadeIn('slow');
- });
- setTimeout(function() {
- retorno.fadeOut('slow').empty();
- }, 5000);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement