jquery – Google Charts API使用$(document).ready方法显示空白屏幕

前端之家收集整理的这篇文章主要介绍了jquery – Google Charts API使用$(document).ready方法显示空白屏幕前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有几个函数使用Google Charts API实例化各种图表。

当我调用他们没有jQuery的$(document).ready方法,一切工作正常。但是用这种方法,我看着黑屏。

为什么?

<script type="text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" charset="utf-8"></script>
<script type="text/javascript" src = "http://www.google.com/jsapi" charset="utf-8"></script>
function drawColumnChart1(){..some code..}
function drawColumnChart2(){..some code..}
function drawGeoChart(){.some code..}

//This works fine.
google.load("visualization","1",{packages:["piechart","corechart","geomap"]});
google.setOnLoadCallback(window.drawColumnChart1);
google.setOnLoadCallback(window.drawColumnChart2);
google.setOnLoadCallback(window.drawGeoChart);



//This doesn't work
$(document).ready(function(){
    google.load("visualization","geomap"]});
    google.setOnLoadCallback(window.drawColumnChart1);
    google.setOnLoadCallback(window.drawColumnChart2);
    google.setOnLoadCallback(window.drawGeoChart);
});

更新
这里是我在Firebug中得到的错误

uncaught exception: [Exception... "Could not convert JavaScript argument"  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: http://www.google.com/jsapi :: Q :: line 20"  data: no]
http://www.google.com/jsapi
Line 22

解决方法

google.setOnLoadCallback with jQuery $(document).ready(),is it OK to mix?

可能是最接近的答案,Ryan Wheale对下面的答案也可能是有帮助的。

Is it ok to use google.setOnLoadCallback multiple times?

猜你在找的jQuery相关文章