jquery preload the page loaded via load() method

ajax, jquery, preload

Solution

var function_for_display_animation = function(){
   //display animation
}
var function_for_remove_animation = function(){
   //remove animation
}

function_for_display_animation();
$(selector).load('page.php',function_for_remove_animation);

or:

$().ajaxSend(function(evt, request, settings){
    //start animation
});

$().ajaxComplete(function(event,request, settings){
    //end animation
 });

$(selector).load('page.php', function(){
    //work
});

Problem

I'm trying to do something like boxy or facebox or lightbox...and so on. The only problem is that I don't know how to preload the page that is loaded into the box via load() method. It should work like this: - It pops the box - Loading animation is added - When the page is loaded the animation disappears So i need to know when the page is loaded to remove the animation.

Original source