Iladarsda
Iladarsda

Reputation: 10696

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?

Upvotes: 0

Views: 1481

Answers (2)

psarid
psarid

Reputation: 450

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.

Upvotes: 3

N.P
N.P

Reputation: 245

I looked at both of your pages. Why don't you modify your design so that when user clicks your link, you run the code to generate the page i.e instead of using $('#div').load('chart.html'), run the code from the chart.html page here directly.

I think part of the problem here is that when you issue the load(cha

Upvotes: 0

Related Questions