Why does google.load cause my page to go blank?

前端 未结 5 1771
花落未央
花落未央 2020-11-29 02:45

Well, this looks strange but I\'m not able to find a solution.

Why in the world does this fiddle http://jsfiddle.net/carlesso/PKkFf/ show the page content and, then

5条回答
  •  被撕碎了的回忆
    2020-11-29 03:00

    You don't need to set timeout. There is another way:

    $.getScript("https://www.google.com/jsapi", function () {
         google.load('visualization', '1', { 'callback': 'alert()', 'packages': ['corechart'] });
    });
    

    Explanation:

     function () {
         google.load('visualization', '1', { 'callback': 'alert()', 'packages': ['corechart'] });
     }
    

    will be executed ​​after successful load JSAPI script, then alert() will be executed ​​after successful google.load()

提交回复
热议问题