Hi there
I have a page with a few links and a div, on the same page that I will load other content into. Some of that content is google visualizations charts.
Just as a test, I popped in the google line chart code. The page loads well on its own, but when I try to load it into div (using jQuery), it doesn
t work. Firefox says transfering data from google.com and does nothing, and IE 6 has a JS error saying google
is undefined.
I don`t see why this would be a problem, but the page is on an intranet...if this helps troubleshooting.
Thanks for any and all help in advance..
Here is the code that loads the mainContent.html file into the div.
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#A2W").click(function(){
$("#loadContent").load("mainContent.html");
});
});
</script>
Contents of the mainContent.html
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["linechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Year');
data.addColumn('number', 'Sales');
data.addColumn('number', 'Expenses');
data.addRows(4);
data.setValue(0, 0, '2004');
data.setValue(0, 1, 1000);
data.setValue(0, 2, 400);
data.setValue(1, 0, '2005');
data.setValue(1, 1, 1170);
data.setValue(1, 2, 460);
data.setValue(2, 0, '2006');
data.setValue(2, 1, 860);
data.setValue(2, 2, 580);
data.setValue(3, 0, '2007');
data.setValue(3, 1, 1030);
data.setValue(3, 2, 540);
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240, legend: 'bottom', title: 'Company Performance'});
}
</script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>