| By Kurt Cagle | Article Rating: |
|
| March 8, 2007 09:45 PM EST | Reads: |
5,187 |
This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs for the special pre-order price, click here for more information. Aimed at everyone from enterprise developers to self-taught scripters, Real-World AJAX: Secrets of the Masters is the perfect book for anyone who wants to start developing AJAX applications.
AJAX isn't so much a single technology as it is a set of technologies that are now all part of most contemporary browsers. Because of this factor, it's sometimes difficult to explain what precisely AJAX is, especially the degree to which XML or JavaScript predominates.
This chapter will explore most of the canonical elements of AJAX on the client and get into some of the grittier details about how exactly an AJAX application works. It will also stray a bit off course and show how AJAX applications can use some of the more advanced capabilities on browsers (such as XPath and XSLT) to simplify the underlying development process, though perhaps at the cost of some portability.
The Essential AJAX Pieces
This should be a no-brainer. AJAX stands for Asynchronous JavaScript and XML so it stands to reason that AJAX would have both of these as core pieces (and it does, though interpreting the role of XML varies considerably from user to user in the AJAX space). However, AJAX generally involves considerably more than just these two technologies.
On the client, in particular, what has come to be called AJAX can best be broken down into the following areas:
JavaScript: This provides the scripting language for performing most of the actions (and generally for setting up event management).
XMLHttpRequest: This particular component makes communication between the client and server
possible from within a Web page.
HTML/XML Document Object Model: This provides a way of describing a Web page as a tree of
interconnected objects.
Cascading Style Sheets (CSS): This language makes it possible to change the visual styling of the page to alter its presentation layer.
Besides these four elements, there are two more that are found in Internet Explorer and Mozilla Firefox:
XSLT: This transforms XML content into other XML content and works quite effectively for building rich objects from data streams.
XPath: This provides a way of navigating around complex XML structures more readily.
These will be covered in greater depth at the end of this chapter.
Whole books have been written on all of these topics, so my goal here is not to teach the basics of JavaScript, DOM programming, or CSS. Instead, I'll be looking at those techniques that may be a little more advanced, but hopefully also be of more use to you as developers. Please check out the references at the end of this book for more information on each of the core technologies.
Examining JavaScript
JavaScript (or ECMAScript, as it's formally known) has been around in various forms since early 1994. It's found in all contemporary Web browsers, and in slightly modified form in the Macromedia/Adobe Flash player, in Adobe PDF, and as a scripting language on both Windows- and Linux-based systems. It's used as the binding language of choice in the Mozilla Firefox and Thunderbird applications
Despite this fairly impressive use record, until comparatively recently JavaScript has been maligned as being too lightweight to be useful in real-world applications, but its gradual re-emergence as part of AJAX has left those JavaScript developers who understood the power of their "light" language feeling more than a trifle smug.
While it's easy to look at JavaScript as being, as its name implies, a scripted variant of Java, this impression is in fact somewhat erroneous. Java is a strongly typed language with an elaborate inheritance mechanism and a foundational class system with classes numbering in the thousands. It has only recently branched into type templates and reflection.
JavaScript, on the other hand, views classes as being particular variants of functions, envisions objects as little more than bundled collections of properties and methods, dynamically assigns type depending on the context, and has only a handful of "core" objects and no foundational class system to speak of. Indeed, while it's possible to inherit classes in JavaScript, in point of fact it's usually far more effective to keep inheritance down to an absolute minimum.
These differences have made for very different ways of programming JavaScript compared to Java. Add to this the question of scope – JavaScript is typically used to automate Web page manipulation and, as such, is generally far more transient than most Java applications – this leads to a situation where the best way to learn JavaScript seriously is to forget that you ever learned Java and take it from scratch.
This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs, click here to order.
Published March 8, 2007 Reads 5,187
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Kurt Cagle
Kurt Cagle is a developer and author, with nearly 20 books to his name and several dozen articles. He writes about Web technologies, open source, Java, and .NET programming issues. He has also worked with Microsoft and others to develop white papers on these technologies. He is the owner of Cagle Communications and a co-author of Real-World AJAX: Secrets of the Masters (SYS-CON books, 2006).
- Kindle 2 vs Nook
- Is Cloud Computing Like Teenage Sex?
- GovIT Expo Highlights Cloud Computing
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Cloud Computing Can Revitalize Your Career as Software Developer
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Virtualization Journal "Readers' Choice Awards" Voting Is Now Open
- Einstein, Sharks and Clouds: IT Security in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Amazon Web Services Database in the Cloud
- Virtualization Expo Call for Papers Deadline December 15
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Is Cloud Computing Like Teenage Sex?
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Ulitzer News: Search vs New Media
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Confessions of a Ulitzer Addict
- GovIT Expo Highlights Cloud Computing
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- Linus' Top Ten SCO Barbs
- A Closer Look at Damn Small Linux
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Where Are RIA Technologies Headed in 2008?
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- i-Technology Viewpoint: The New Paradigm of IT Buying
- Is Linux Desktop-Ready Yet...or Not?


































