I am using a Google chart (termcloud) to display some data. I can get this working fine as a static feature on the page, however when I try to load the chart and its assets via ajax it just seems to keep throwing an error:
'TypeError: google.load is not a function'
Here is my ajax function:
$("li.contentpanel").click(function() {
$("#content-panel").show();
$('#content-panel').animate({
width: '540'
}, 500, function() {
var dataString = 'alert=1';
$.ajax({
type: "POST",
url: "<?php echo site_url($topicmaplink);?>",
data: dataString,
cache: false,
success: function(html){
$("#content-panel #inner").html(html);
}
});
});
This is the page that is called:
(JSAPI and termcloud plugin files are loaded at top of this page)
$(function() {
google.load("visualization", "1");
google.setOnLoadCallback(draw);
function draw() {
data = new google.visualization.DataTable();
data.addColumn('string', 'Label');
data.addColumn('number', 'Value');
data.addColumn('string', 'Link');
data.addRows(<?php echo sizeof($topics);?>);
<?php
$trans = array("ã" => "a", "³" => "3", "º" => "0", "â" => "a",
"¡" => ";", "'" => "", "\n" => "",'"' => '');
shuffle($topics);
for($j=0;$j<sizeof($topics);$j++){
$nonforeignkeyword = strtr($topics[$j]['keyword'],$trans);
$totalnumber = $topics[$j]['occurrence'];
echo 'data.setValue('.$j.', 0, "'.trim($nonforeignkeyword).'");';
echo 'data.setValue('.$j.', 1, '.$totalnumber.');';
echo 'data.setValue('.$j.', 2, "'.$partlink.'/searchterm||'.trim(rawurlencode($nonforeignkeyword)).'");';
}
?>
var outputDiv = document.getElementById('cp-tmap');
var tc = new TermCloud(outputDiv);
tc.draw(data, null);
}
});
Even when I remove the JSAPI and termcloud js files from the page being called via ajax and place them on the same page that it is being called to the page seems to redirect to google.com and hang on a blank page.
Does anyone know where I am going wrong here?
Thanks in advance for the help