AJAX
  Home arrow AJAX arrow Page 4 - Using the google.load() Method with Google`s Ajax Libraries API
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
AJAX

Using the google.load() Method with Google`s Ajax Libraries API
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2009-01-26


    Table of Contents:
  • Using the google.load() Method with Google`s Ajax Libraries API
  • Review: delivering the Prototype JavaScript library without compressing its source files
  • Serving the jQuery library without using compression
  • Source code for the sample Ajax application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using the google.load() Method with Google`s Ajax Libraries API - Source code for the sample Ajax application
    ( Page 4 of 4 )

    In the section that you just read, I explained how to develop a primitive Ajax application that uses the Goggle API to download the jQuery library without using compression. Nevertheless, this application would look rather incomplete if I didn’t list the signature of its remaining source files.

    So, here they are:


    (definition for 'ajax_file_reader.htm' file)


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Reading file contents with jQuery library (uses Google API)</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: bold 18pt Arial, Helvetica, sans-serif;

    color: #000;

    }

    #filecontents{

    width: 600px;

    padding: 10px;

    border: 1px solid #999;

    font: normal 10pt Arial, Helvetica, sans-serif;

    color: #000;

    }

    </style>

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

    <script>

    // load jQuery library with Google API (loads uncompressed source file)

    google.load("jquery","1.2",{uncompressed:true});

    google.setOnLoadCallback(function(){

    $("#btn").click(function(){

    $.get("read_file.php",function(fileContents){$("#filecontents").html(fileContents);});

    });

    });

    </script>

    </head>

    <body>

    <h1 id="header">Reading file contents with jQuery library (uses Google API)</h1>

    <p><input type="button" id="btn" value="Read File Now!" /></p>

    <div id="filecontents"></div>

    </body>

    </html>



    definition for 'read_file.php' file)


    <?php

    if(!$contents=file_get_contents('data.txt')){

    trigger_error('Error reading file contents',E_USER_ERROR);

    }

    echo $contents;

    ?>



    (definition for 'data.txt' file)


    These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file. These are contents of sample file.


    Now that you have at your disposal the entire source code of the above Ajax program, surely you’ll be able to test much more easily how long it takes to run when the jQuery library is delivered compressed and uncompressed from Google’s servers. Whether you decide to employ this Google API or not, one thing is certain: you'll have fun playing around with it!

    Final thoughts

    After this long and hopefully instructive journey, we’ve come to the end of the series. As was demonstrated by the code samples included in the different tutorials, learning to use Google's Ajax Libraries API is really very simple. The whole process is reduced to working with a couple of JavaScript methods and nothing else. Now, it’s up to you to decide whether or not to use this API when working with your preferred JavaScript package.

    See you in the next tutorial!



     
     
    >>> More AJAX Articles          >>> More By Alejandro Gervasio
     

       

    AJAX ARTICLES

    - PHP AJAX Form Validation
    - Completing a User-Defined CSS Website with P...
    - Create a User-Defined CSS Website with PHP
    - Build A Better Twitter Chat Client Than Cham...
    - Using Division Equations to Make Web Forms S...
    - Using Integer Multiplication to Protect Web ...
    - Using Simple Checksums for Web Form Verifica...
    - Protecting Web Forms with AJAX
    - Using Prototip with AJAX
    - Using Prototip
    - Using the google.load() Method with Google`s...
    - How to Handle Ajax Errors
    - Uncompressing Source Files with Google`s AJA...
    - Using the jQuery Framework with Google`s Aja...
    - Using Google`s Ajax Libraries API




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek