[英]Google Chrome & Visualization google.setOnLoadCallback fails in ajax
See http://jsfiddle.net/QJVUr/1/ for an example - works fine in FF but not in Chrome. 有关示例,请参见http://jsfiddle.net/QJVUr/1/-在FF中可以正常工作,但在Chrome中不能正常工作。
On the opposite side; 在另一边 removing the google.setOnLoadCallback works in Chrome but not Firefox: http://jsfiddle.net/RTQ5S/ 删除google.setOnLoadCallback可以在Chrome中使用,但不能在Firefox中使用: http : //jsfiddle.net/RTQ5S/
Any ideas on a compromise? 有什么折衷办法吗?
I am guessing Chrome doesn't run the setOnLoadCallback because it has already loaded. 我猜Chrome不会运行setOnLoadCallback,因为它已经加载了。
I would suggest two things: 我建议两件事:
window.addEvent('domready', function(){..});
因此,根据您的摆弄,我将替换window.addEvent('domready', function(){..});
with google.setOnLoadCallback(function(){...});
使用google.setOnLoadCallback(function(){...});
. 。 Hopefully that helps; 希望能有所帮助; I'm not sure if there's a reason they way you're doing things the way you are that means the above options aren't what you're looking for, so if that's the case feel free to give more specifics in your question. 我不确定他们是否有理由按照自己的方式行事,这意味着上述选项不是您想要的,因此,在这种情况下,您可以随意提出更多问题。
Instead of using setOnCallback set the callback in the library load. 代替使用setOnCallback设置库加载中的回调。
See http://jsfiddle.net/QJVUr/10/ 见http://jsfiddle.net/QJVUr/10/
google.load('visualization', 1, {packages:['corechart'], callback: drawChart});
Per Google dev docs, if library is already loaded, it is not loaded again, rather the callback is immediately called. 根据Google开发文档,如果已经加载了库,则不会再次加载该库,而是会立即调用该回调。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.