saimcan
saimcan

Reputation: 1762

Loading gif until page completely loads

I am trying to display a loading GIF and display it until a page has completely loaded.

Here is my jQuery/Javascript code:

$(document).ready(function(){
   $('#myTab a').on('load', function (e) {
        e.preventDefault();
        $(this).tab('show');
    },onLoadSomeFunction());
}

onLoadSomeFunction() leads my page to get some values and load them into it.

How can I show my loading gif until all the page loading process ends ?

Upvotes: 0

Views: 912

Answers (2)

Gaganpreet Kaur
Gaganpreet Kaur

Reputation: 371

//Try using this following code
<img src="loader.gif" class="gif_image"/>

//Jquery
$(document).ready(function(){  
   
   $('#myTab a').on('load', function (e) {
        e.preventDefault();
        $(this).tab('show');
    },onLoadSomeFunction());
}

$(window).load(function()
{
   $('.gif_image').hide();
}); 

Upvotes: 1

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72289

    please try this:- 
$(document).ready(function(){
       $('#myTab a').on('load', function (e) {
            e.preventDefault();
      $(this).tab('show'); or $('#load_img/message').show();// div having loading image/message and initially property hidden

        },onLoadSomeFunction()); or success : function(html){
               //your functionality after success
                 $('#load_img/message').hide(); // hide the loading image/message
            }
    }

Upvotes: 1

Related Questions