show GIF image with jQuery

0

the following code is to validate a logeo

$(document).ready(function(){  
    $("#login_a").click(function(){  
        $("#shadow").fadeIn("normal");  
         $("#login_form").fadeIn("normal");  
         $("#user_name").focus();  
    });  
    $("#cancel_hide").click(function(){  
        $("#login_form").fadeOut("normal");  
        $("#shadow").fadeOut();  
   });  
   $("#login").click(function(){  

        username=$("#user_name").val();  
        password=$("#password").val();  
         $.ajax({  
            type: "POST",  
            url: "login.php",  
            data: "name="+username+"&pwd="+password,  
            success: function(html){  
              if(html=='true')  
              {  
                $("#login_form").fadeOut("normal");  
                $("#shadow").fadeOut();  
                $("#profile").html("<a href='logout.php' id='logout'>Logout</a>");  

              }  
              else  
              {  
                    $("#add_err").html("Usuario o password incorrectos");  
              }  
            },  
            beforeSend:function()  
            {  
                 $("#add_err").html("Cargando...")  
            }  
        });  
         return false;  
    });  
});  

On the line

$("#add_err").html("Cargando...")

How can I show a .gif image instead of the "Loading ..." message

    
asked by Jose Luis GP 06.04.2017 в 23:46
source

1 answer

2

On your div you can load an img element with the gif

<div id="add_err">
<img src="nuestra_animacion.gif" />
</div>
//Es script después del ready
$('#add_err').hide();
//En la linea para mostrar tu mensaje de cargando lo cambiarías por esto
$('#add_err').fadeIn(1000);
    
answered by 06.04.2017 / 23:55
source