Question

Hi i have been adding some animations to my website like on the login page etc

however I first found that the Animation executes but not the PHP code and when i get the PHP code to execute then the Animation doesnt work... PHP code is more important however it seems even if i use the form.submit() function in jquery the PHP code never triggers. i know this as i tried alternate methods and it works without the jQuery.

i am using 1.9.0 and here is the jQuery code

jQuery('#loginform button').click(function()
        {
            if(!jQuery.browser.msie) 
            {
                if(jQuery('#username').val() == '' || jQuery('#password').val() == '') 
                {
                    if(jQuery('#username').val() == '') jQuery('#username').addClass('error'); else jQuery('#username').removeClass('error');
                    if(jQuery('#password').val() == '') jQuery('#password').addClass('error'); else jQuery('#password').removeClass('error');
                    jQuery('.loginwrap').addClass('animate0 wobble').bind(anievent,function()
                    {
                        jQuery(this).removeClass('animate0 wobble');
                    });
                } 
                else 
                {
                    jQuery('.loginwrapper').addClass('animate0 fadeOut').bind(anievent,function()
                    {
                        $.post(username, {username});
                        $.post(password, {password});
                        jQuery('#loginform').submit();
                    });
                }
                return false;
            }
        });

as you can see, originally i got the code to post from the jquery however the animation does not run no matter what i tried.

can anyone tell me why... or what way am i supposed to make it that the animation happens then the PHP???

Was it helpful?

Solution

Do you have the above JS wrapped such that it waits to execute until after the document has finished loaded? If you don't, what may be happening is that the javascript is trying to act on elements that have not yet been rendered. So, perhaps #loginform button does not yet exist when it is attempting to bind to that element.

Wrap your JS in this:

jQuery(function(){
    // All JS that executes on load here.
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top