我试图通过模态弹出窗口加载Google Chart。我通过独立页面可以正常工作的代码,但是当通过弹出窗口加载时,我会收到一个"未捕获的ReferenceError:google未定义"错误。
popup.html
<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 = google.visualization.arrayToDataTable([
['Date', 'Price'],
[new Date(2014,9,18,14,20,41), 2.30],[new Date(2015,0,06,07,12,04), 1.00]
]);
function hide_chart()
{
view = new google.visualization.DataView(data);
view.hideColumns([1]);
chart.draw(view, options);
}
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data);
}
$(window).resize(function(){
drawChart();
});
</script>
<div id="chart_div"></div>
加载弹出窗口的Jquery:
$('#modal').load("/pages/popup.html", function () {
});
我试过了:
我们非常感谢任何建议。
亲切的问候