jQuery/Javascript - "no es un error de función" pero la función está definida

Hi i have this piece of my code:

<script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">

    $(function(){
        $('#invite').on('click',function(){
            if(!$('#invite').hasClass('disabled') ){
                invite($("#email").val());
            }
        });
        $('#email').on('keyup',function(e){
            if(e.which == 13 && !$('#invite').hasClass('disabled') ){
                invite($("#email").val());
            }
        });


    });
    function loading(){

        window.loading = setInterval(function(){
        $(".logo img").fadeTo(500,0.1).fadeTo(550,1);
    },1600); 

    }
    function unloading(){
      $('.logo img').fadeTo(0,1);
      clearTimeout(window.loading);
    }
    function invite(_email){
        $.ajax({
            type:'POST',
            url:_config_base_url+'/invite/get_invite',
            data:{email:_email},
            dataType:'json',
            error:function(){
                unloading();
                $("#invite").removeClass('disabled');
               notify("Sorry an error occured, please try again later",2000);
                $("input").focusout();
            },
            beforeSend:function(){
                loading();
                notify_destroy();
                $("#invite").addClass('disabled');
                $("input").focusout();
            },
            success:function(json){
                unloading();
                $('body').trigger('focus');
                $("#invite").removeClass('disabled');

                if(json.error == 'yes'){

                    notify(json.error_message,false,false);
                }else{
                    $("#email").val("");
                    notify(json.confirm_message,false,'notify-info');
                }

                $("input").focusout();
            }

        });
    }
    </script>

when i launch the ajax request for the first time, everythings works perfect.

But, when i try re-launch the request it always returns : "error: loading is not a function" and the code line involved is this one:

 beforeSend:function(){
                loading();

i have no idea what's happening there :/

preguntado el 05 de mayo de 13 a las 09:05

1 Respuestas

window.loading = setInterval(function(){

In the above line in function loading, loading is being redefined to setInterval return value because of which loading is no longer a function after the first invocation.

contestado el 05 de mayo de 13 a las 09:05

yep changed to ventana.cargar and it works, you rock! thanks dude - itsme

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.