google Api javascript dynamic loading

google dynamic loading api can not only own the ajax loaded modules can also be loaded at the same time many of the three popular modules, such as jQuery, dojo, yui, etc.. This article has a way of dynamically loaded briefly.

This dynamic loading is very simple, first of all contain google dynamic loading api itself. Js files, the code is as follows:

<script type="text/javascript" src=""></script>

Then google.load (module name, version number) to load modules such as:

google.load("maps","2"); // Load the gmap
google.load("search","1");// Add search
google.load("jquery","1.3.2");// Load jquery
google.load("dojo","1.3.0");// Load the dojo  

The final step is very important, we want to run google.setOnLoadCallBack (your initial function). Why do want to run this function? Because of your own function in the initial call had not yet been loaded if the module to complete the code, the browser will error, your ajax program to stop running on the interrupt.

A complete example is:

    <script type="text/javascript"
    <script type="text/javascript">
      google.load("maps", "2");
      google.load("search", "1");

      // Call this function when the page has been loaded
      function initialize() {
        var map = new google.maps.Map2(document.getElementById("map"));
        map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);

        var searchControl = new;



Are listed in the following url to google loader api to load the module and its version number.
Self-produced components to load:
To load third-party components:

分类:AJAX 时间:2009-09-22 人气:1028
blog comments powered by Disqus


  • Dynamic loading JS script four kinds of methods 2009-02-27

    To achieve dynamic loading JS script has four kinds of methods: 1, direct document.write <script language="javascript"> document.write ( "<script src='test.js'> <\ / script>"); </ script> 2, dynamic script to ch

  • Dynamic loading javascript 2009-05-13

    / ** * Dynamic loading JS files * / var Faceye = ( version: 1.0, / ** * Easy access to httpRequest * / httpRequest: function () ( var xRequest = null; if (window.XMLHttpRequest) ( xRequest = new XMLHttpRequest (); ) Else if (window.ActiveXObject) ( x

  • Dynamic loading javascript files 2010-12-23

    Dynamic loading javascript? A very popular topic, if you already know how to dynamically load external javascript, then you can skip this article to read the rest. If you do not know how to dynamically load an external javascript file, please be pati

  • AJAX + XML-based XLoadTree dynamic loading of components of the document tree JS 2009-06-26

    Tree node has recently started to load and read a good article, look around them to share BeanSoft evaluation: This component tree is not perfect, but it is based on self-object-oriented, based on the AJAX + XML + DOM, the head is also relatively sma

  • Ajax dynamic loading tree menu 2009-11-06

    Recently, the company requires a dynamic loading of the tree menu, first open the page when loading the first level node, point to the first floor with Ajax after any node to the node under the dynamic loading of child nodes, found in the online did

  • JavaScript object dynamic loading technology 2010-04-28

    What is a JavaScript object dynamic loading JavaScript dynamic loading (JavaScript Object Dynamic Loading) - The reason is called dynamic, is for there to be another form of the usual static load. JavaScript typical static loading method is through <

  • JavaScript dynamic loading 2010-08-20

    As the name suggests is the judge to decide according to conditions or not to load the JavaScript, is to determine if simple Well, the key is loaded: Quote <script language="javascript" type="text/javascript"> var nSel = document

  • [YUI source learning] YUI Get Utility dynamic loading mechanism 2010-09-01

    [Note] YUI before the analysis is aimed at YUI 2.8 version. On the dynamic loading First is that on which a method of dynamic loading and dynamic loading have any effect. Sometimes the development page, you need to load a lot of js files. Js file for

  • 尝试在让script的type属性等于text/html 2015-03-11

    我们可以在script片断中定义一个被JS调用的代码,但代码又不在页面上显示,这时,我们可以使用下面的方法;当script中的type等于text/html时我们可以做些什么呢?感兴趣的朋友可以了解下啊 我们可以在<script>片断中定义一个被JS调用的代码,但代码又不在页面上显示,这时,我们可以使用下面的方法: <script id="commentTemplate" type="text/html"> <li> <di

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.044 (s). 13 q(s)