fadeout, load, fadein, how to wait for load before fadein?

Brad Bansner
Brad Bansner used Ask the Experts™
on
In attached code, is it possible to add something to this that will wait for the "load" statement to finish before the fadeIn? Thank you.
$('#panelleft').fadeOut(500);
$('#panelleft').load('https://www.domain.com/script.asp);
$('#panelleft').fadeIn(1500);

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
Try this :
$('#panelleft').fadeOut(500);
$('#panelleft').load('https://www.domain.com/script.asp, function() {
         // load completed, fade in
         $('#panelleft').fadeIn(1500);
});

Open in new window

Hi,

this should do the job:

$('#panelleft').fadeOut(500);
$('#panelleft').load('https://www.domain.com/script.asp', function(){
   $('#panelleft').fadeIn(1500);
});

Open in new window

Brad BansnerWeb Developer

Author

Commented:
Cool, I think that does it. Just adding a comma and then the next command, forces it to wait?
Hi,

the method invokes jQuery.ajax() to fetch stuff from the server. You can pass it an callback for the complete-event as optional argument.

see this for further information:
http://api.jquery.com/load/

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