CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

Using the JQuery Library hosted by Google CDN (Content Distribution Network) in ASP.Net Applications
Submitted By Satheesh Babu B
On 1/27/2009 6:53:15 AM
Tags: asp.net,CodeDigest,JQuery  

Using the JQuery Library hosted by Google CDN (Content Distribution Network) in ASP.Net Applications

 

Google's Content Distribution Network(also, AJAX Libraries API ) hosts most widely used open source JavaScript libraries which can be used globally across the websites. The main advantage of using google's CDN is they manage all the bug fixes, recent updates and provide a high speed access due to better caching, etc.   

Visit the following link to know more,

http://code.google.com/apis/ajaxlibs/

 

If we are hosting a public website that uses JQuery, then it is advisable to use this Google's feature to host the JQuery library for us.

 

How to use in ASP.Net Application?

We can load the JQuery library by using Google AJAX API Loader's google.load() method.

 

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

<script type="text/javascript">

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

  google.setOnLoadCallback(function() {

  alert("Welcome to Google Hosted JQuery!!");

  });

</script>

 

In the above code snippet, the google Ajax loader will load the latest JQuery version file i.e. specifying the version "1" will load the latest revision available at that time for version 1.

 

 We can also access JQuery library in traditional way like,

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

<script type="text/javascript">

    $(document).ready(function() {

alert("Welcome to Google Hosted JQuery!!");

 });

</script>

 

Thanks to Dave for sharing this valuable info!

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..