I’m having a problem loading a PHP file using .get (even used .load) with the google calendar Javascript included in the file. Here is an example:
index.php
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Task');
data.addColumn('number', 'Hours per Day');
data.addRows([
['Work', 11],
['Eat', 2],
['Commute', 2],
['Watch TV', 2],
['Sleep', 7]
]);
var options = {
title: 'My Daily Activities'
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
/*
$(document).live('ready',function(){
$('#insidefolders').load('file.php', function () {
});
});
*/
$.get('file.php', function show_province(e){
$('#insidefolders').html(e);
});
});
</script>
</head>
<body>
<div id="insidefolders"></div>
</body>
file.php:
<div id="chart_div" style="width: 320px; height: 150px;" ></div>
The thing is, I need the chart to be shown in the file.php file. I tried to create it inside the index.php and then clone it, but that did not work either.
So again, I’m just trying to load file.php inside index.php, but the google calendar javascript inside index.php won’t load to the div inside index.php
Any help or suggestions?
I don’t understand perfectly the problem, but maybe you should initialize the calendar in the callback of $.get