Preloading the jquery page loaded by the load () method

I am 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 loaded into the window using the load () method.

It should work as follows:

  • A window appears
  • Added loading animation
  • When the page loads, the animation disappears

So, I need to know when the page loads to remove the animation.

+5
source share
2 answers
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
});
+3
source

, , , , , , .

, . JavaScript.

, $(document).ready() AJAX . AJAX JS .

+1

All Articles