Search code examples
jquerygoogle-visualizationjquery-load

Google Chart Tool does not work with jQuery .load


I'm trying to use jQuery .load to load separate file with Google Chart into #div.

If you call the file itself - Direct Chart File URL - it does work.

But, when I'm trying to load it with .load:

$('#link').click( function(){

    $('#div').load('chart.html');   

}); 

Here is the file including jquery .load: File with jQuery load URL

Firebug is throwing an error: google is not defined.

hat is the problem? Why this doesn't work if directly called file does work?


Solution

  • I had this problem a long time ago. Here's the solution.

     $('#link').click( function(){
    
          $('#div').load('chart.html', function () { drawChart();});   
    
     }); 
    

    ** Make sure on the page you are trying to load, the function to load the chart is called drawChart(); -- this is the default name that Google gives, so it is likely that you have this.