Reputation: 1518
http://amyyatsuk.com/contact.html
I have an HTML form that uses jQuery ajax() to submit to a php processing page. In the success function of the ajax() call I have the following:
success: function() {
$('#contactForm').fadeOut(1000);
$('#hidden').delay(.1000).fadeIn(1500);
return false;
These effects are simultaneous. I'm looking to fade in the hidden div only after the contact form is fully faded out.
Thanks
Upvotes: 4
Views: 2438
Reputation: 318212
There's a handy built in callback for that :
success: function() {
$('#contactForm').fadeOut(1000, function() {
$('#hidden').fadeIn(1500);
});
return false;
Upvotes: 3
Reputation: 2896
You can add a second parameter to your fade out that contains the fade in you want to do. E.G
success: function() {
$('#contactForm').fadeOut(1000,function(){
$('#hidden').fadeIn(1500);
});
return false;
This will only fire once the fadeOut completes. Covered in the API Docs - http://api.jquery.com/fadeOut/
Upvotes: 1
Reputation: 14862
The fadeOut and fadeIn effects contain an onComplete callback (optional):
$('#contactForm').fadeOut(1000, function(){
$('#hidden').fadeIn(1500);
});
Upvotes: 6