Submit after animation is complete

dextermorgan
dextermorgan used Ask the Experts™
on
I have this bit of Jquery - when the submit button is clicked, the form scrolls up and the form is submitted, but the animation does not complete before the form is submited - and page refreshed. I want the animation to complete before the form is submitted.

Thanks
$('#Register_submit').click(function() {
                $('#second-form').slideUp(800);
            });

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In the method shown in the link below,
http://api.jquery.com/slideUp/

you can call the form-submit function in the callback method of slideup

Do something like this. Note how I have used a type="button" instead of type="submit"
<div id="theFormDiv">
<form id="theForm" action="index.php" method="post">
<button id="Register_submit" type="button" value="Submit">
</form>
</div>

<script type="text/javascript">
$('#Register_submit').click(function() { 
       $('#theFormDiv').slideUp(800, function(){
            $("#theForm").submit();
      }); 
});
</script>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial