Jquery Cannot call method 'load' of undefined
<p>I'm using jquery to load google maps after button toggle:</p>

<pre><code>function loadScript() {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://maps.googleapis.com/maps/api/js?v=3.11&amp;key=AIzaSyCK3XUMWOH0GIiuj3VeprakKZXoo_nDV08&amp;sensor=true&amp;' +
        'callback=initialize';
    document.body.appendChild(script);
}

(function ($) {
    $(document).ready(function () {
        //Show map on category pages
        $(function () {
            $("#showonmap a").toggle(function () {
                $(this).children("#show_map").hide();
                $(this).children("#hide_map").show();
                //Reveal google maps multi
                //First create empty divs, if they exist don't create them
                if ($("#googlemap_multi").length == 0) {
                    $("#subheadergradient").before('&lt;div class="googlemap_margin"&gt;&lt;/div&gt;&lt;div id="googlemap_multi"&gt;&lt;/div&gt;&lt;div class="googlemap_margin"&gt;&lt;/div&gt;');
                }
                $(".googlemap_margin").fadeIn("slow", function () {
                    $("#googlemap_multi").animate({
                        height: 400
                    }, "slow", function () {
                        //load google maps
                        loadScript().load();
                    });
                });
            }, function () {
                $(this).children("#hide_map").hide();
                $(this).children("#show_map").show();
                //Hide google maps multi
                $("#googlemap_multi").animate({
                    height: 0
                }, "slow", function () {
                    $(".googlemap_margin").fadeOut("slow");
                });
            });
        });
    });
}(jQuery));
</code></pre>

<p>But this generates error:</p>

<pre><code>Uncaught TypeError: Cannot call method 'load' of undefined localhost:482
(anonymous function) localhost:482
d.complete jquery.min.js:4
f.fx.step jquery.min.js:4
h jquery.min.js:4
f.extend.tick
</code></pre>

<p>So toggle back function never gets executed.</p>

<p>This part:</p>

<pre><code>//Hide google maps multi
$("#googlemap_multi").animate({height: 0},"slow", function(){
    $(".googlemap_margin").fadeOut("slow");
});
</code></pre>

<p>What is the problem?</p>

<p>ty.</p>
