我正在使用Google圖表(termcloud)顯示一些數據。當我嘗試加載圖表,並通過AJAX其資產似乎只是不斷拋出一個錯誤,我能得到這個工作的罰款,頁面上的靜態功能,但是:TypeError:使用ajax時google.load不是函數
'TypeError: google.load is not a function'
這裏是我的ajax功能:
$("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);
}
});
});
這是被稱爲頁:
(JSAPI和termcloud插件文件在這個頁面的頂部加載)
$(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);
}
});
即使當我從頁面移除JSAPI和termcloud js文件通過ajax調用並將它們放置在它被調用到頁面的同一頁面上似乎重定向到google.com並掛在空白頁面上。
有沒有人知道我在哪裏錯了嗎?
在此先感謝您的幫助
http://stackoverflow.com/questions/15575354/google-load-never- calls-callback鏈接中問題的答案似乎解決了這個問題。 – user2418202