As you may have guessed, rebuilding the Ajax application developed in the prior section by using the Google API only requires a few minor changes that you’ll surely grasp in a snap. However, the best way to demonstrate that this is true is by means of functional code. Thus, here’s the modified version of the mentioned Ajax application, where jQuery’s source file is served via the Google API:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Reading file contents with jQuery library (uses Google API)</title>
font: bold 18pt Arial, Helvetica, sans-serif;
border: 1px solid #999;
font: normal 10pt Arial, Helvetica, sans-serif;
// load jQuery library with Google API
<h1 id="header">Reading file contents with jQuery library (uses Google API)</h1>
<p><input type="button" id="btn" value="Read File Now!" /></p>
As shown above, this sample Ajax program now loads the jQuery package via the Google API. This procedure should be quite familiar to you, since it looks very similar to the example developed in the first article, where the API was used to serve the Prototype library.
In this case, not only is the application initialized through the “google.setOnLoadCallback()” method, but it uses the versioning feature for specifying exactly which version of jQuery should be downloaded to the client.
In this second chapter of the series, I went through the development of a sample Ajax-driven application that made use of Google's Ajax Libraries API to work with the jQuery library.
However, as I explained before, each package served through this API is compressed before being sent to the browser. Thus, in the forthcoming article I’ll be discussing how to disable this feature when working with the Prototype framework.
Now that you’re aware of the topic that will be covered in the next part, you don’t have any excuses to miss it!
blog comments powered by Disqus