Google.load - and the message "google undefined"

What do I need to enable in order to make an operator google.load()? I get the error "Google is not defined".

On this page http://code.google.com/apis/ajax/documentation/#DetailedDocumentation
I thought I should add this:

<script type="text/javascript"
        src="http://www.google.com/jsapi?key=ABCDEFG">
</script>

But when I did this, I get the "window.LoadFirebugConsole" not a function.

+3
source share
4 answers

I had the same problem and solved this:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type='text/javascript'>
    function LoadGoogle()
    {
        if(typeof google != 'undefined' && google && google.load)
        {
            // Now you can use google.load() here...
        }
        else
        {
            // Retry later...
            setTimeout(LoadGoogle, 30);
        }
    }

    LoadGoogle();
</script>

The idea is to repeat until Google is determined .

, , , Ajax .

+9

google jsapi script ? script.

    <script src="http://www.google.com/jsapi?key=ABCDE"></script>
    <script type="text/javascript">

    google.load("jquery", "1");

    // Define our onLoad callback
    function OnLoad(){
      alert("Loaded!");
    }

    google.setOnLoadCallback(OnLoad);
    </script>

Google 'AJAX Api Playground' .

+8
+5

, :

<script type="text/javascript" src="http://www.google.com/jsapi" />

chanching :

<script type="text/javascript" src="http://www.google.com/jsapi"></script>

+5

Source: https://habr.com/ru/post/1716353/


All Articles