user2721624
user2721624

Reputation: 43

Jquery: load() function not working for div

I am displaying envision graph in the div(#graph), but it takes time of around 3 to 4 sec to load so in that time i have to display a loading symbol. After the div loads that graph should display but the thing is load function is not working for the div(#graph).

$(document).ready(function(){ 
    $('#graph').append('<img src="images/loader.gif">'); //loading symbol           
     $('#graph').load(function(){

        //data of graph

       }); 
     }); 

    <div id='graph'></div>

Upvotes: 0

Views: 89

Answers (2)

paulitto
paulitto

Reputation: 4673

You shold use url as a first parameter for load method

$('#graph').load('buildgraph.php', function(){
    //data is loaded
}); 

see here

Upvotes: 1

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

That should work, anyway try like this too:

if($('[src="images/loader.gif"]').is(':hidden')){
//do your stuff
}

Upvotes: 1

Related Questions