Slashdot Log In
Foundations of Ajax
Posted by
samzenpus
on Wed Mar 01, 2006 01:41 PM
from the clean-programming dept.
from the clean-programming dept.
Craig Maloney writes "You've no doubt heard about Ajax. Practically every new and exciting application on the web uses some form of Ajax. Google's suite of applications (GMail, Google Maps, etc.), Amazon's A9 search engine, and Netflix use Ajax interfaces to give the user a better browsing experience. By using some pretty basic innovations to current technology, browsers can now deliver content in ways unimaginable only a few short years ago. Foundations of Ajax provides developers who haven't taken the time to look into Ajax a hands-on guide for quickly leveraging these technologies in their own applications." Read on for Craig's review.
| Foundations of Ajax | |
| author | Ryan Asleson and Nathaniel T. Schutta |
| pages | 273 |
| publisher | Apress |
| rating | 8/10 |
| reviewer | Craig Maloney |
| ISBN | |
| summary | A good first-look at Ajax and client-side development using JavaScript, HTML, and CSS. |
Foundations of Ajax starts with a brief history of interactive web-applications, starting from the crudest CGI and Java Applets, and chronicling various interactive technologies (Javascript, Servelets, ASP, PHP, Flash, DHTML, and the various XML browser languages like XUL, XAMJ, etc.). Ajax seems like another acronym in a sea of acronyms, but the authors quickly point out why Ajax can help with the development cycle. Ajax allows the server to validate the user's input, without creating ugly and messy JavaScript validation rules, and it allows the server to use the same rules for input validation on both the client and the server. Unfortunately, Ajax does break some of the conventions users have grown accustomed to in using traditional web applications. XMLHTTPRequest requests aren't stored in the browser history, and it can be confusing to the user to determine what changed on the page after refresh. Issues aside, the book is very encouraging on the prospects of using Ajax in web applications, and invites the reader to use Ajax where it makes sense.
Chapter 2 talks about the request method that makes Ajax possible: XMLHTTPRequest (XHR). The XHR methods are explained with several examples that detail the fundamentals occurring with the request. The examples are very clear, and the entire process is laid out in careful detail, although the Dynamic Object Model (DOM) is mentioned, but not explained until the end of the chapter.
Chapter 3 delves into server communication. It's interesting to note that the authors haven't instantiated a server yet for their Ajax communication, and for the balance of chapter 3, the server is replaced by text files. It's not until the GET/POST examples that the authors start using Servelets. While it may seem strange for the authors to be talking about client/server programming without instantiating a server, it does allow the developer to get their proverbial feet wet without battling server configuration issues. The chapter starts by introducing innerHTML, but then moves to using XML DOM for data transfer from the client. From there, the authors demonstrate a few examples of the server sending XML to the client, and the client sending XML to the server. Happily, the authors weren't content to leave us parsing XML using JavaScript, instead they finish up the chapter by introducing the JSON framework with a few examples.
Chapter 4 is really where the book starts doing very interesting examples with Ajax. It's also, coincidentally, the largest chapter in the book, and the chapter readers will find the most useful reference examples. The book steps through the creation of examples of Simple date validation, Reading response headers for a simple ping application, Dynamically Loading List Boxes, Automatically Refreshing Pages, Progress bar (a personal favorite), Tool tips, Accessing Web Services using REST, and Auto complete. Each example is introduced with a real-world working application as an example (such as the auto complete feature of the Google search engine), and could easily be implemented in a developer's application. I found myself thinking of ways to enhance my code using these techniques.
Following chapter 4's examples, the chapters on creating a developer toolbox, testing scripts using JsUnit, and debugging Javascript seem a bit of a let-down. Chapter 5 outlines various packages for helping JavaScript coders to better spot errors in their code, and create documentation using the JavaDoc-like application JSDoc. There is also a mention of an application for crunching and compressing JavaScript code, as well as the excellent Web Developer Extension. Rounding out the chapter is a brief history of JavaScript, and some advanced JavaScript techniques. Chapter 6 introduces JsUnit and Unit Testing. Chapter 7 talks about JavaScript debuggers, such as Microsoft's Script Debugger, and the very powerful Venkman. The Venkman tutorial is very good, and would be a great starting point for anyone wanting more information on how to use this great tool.
Chapter 8 rounds out the book with the typical "for more information" sites to visit. However, in true Steve Jobs "One more thing" fashion, the authors not only plug their Ajax Framework, but also create a browser-based, Macintosh-like Dashboard application with four widgets. I was all set to finish the book, but the authors quietly slipped the best for last in the final pages of the book, bringing out a complete Mac OSX-like "Dashboard" windowed-environment in a browser complete with the drag-and-drop elements I've most associated with Ajax sites. This is by far the most complicated project in the book, and it make for an excellent ending to an already fine book.
Foundations of Ajax is a great starting point for developers wondering how they can incorporate Ajax into their own web-based projects. One minor gripe I had with this book was the examples looked pale in comparison with their real-world models, but design is hardly the focus of the book. Where Foundations of Ajax shines is it's no-nonsense introduction, implementation, and expansion of the basics of Ajax programming, leaving the reader confidently ready to utilize the concepts within. The authors have seen the potential of Ajax, and competently convey their expertise and enthusiasm for this technology."
You can purchase Foundations of Ajax from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Wow (Score:2)
demo? (Score:2)
(http://assambassador.com/)
Moving target (Score:2)
(http://fak3r.com/)
So... (Score:2)
(http://godgab.org/)
I feel sorry for all the trees... (Score:2)
I feel sorry for all the trees that have to be cut down needlessly so that developers can try to keep up with the latest crappy technology that will obsolete in less than 2 years.
On the bright side, at least its under 300 pages long.
What level? (Score:1)
(http://www.danikar.com/)
see sig. (Score:1)
(http://sharpy.xox.pl/ | Last Journal: Wednesday September 14 2005, @02:12PM)
yep, its a good book (Score:3, Informative)
(http://www.developeradvantage.com/)
Ajax vs. Comet (Score:1)
(http://thepreacher.cac2.net/)
Oh, that Ajax.
Nevermind...
Effective Ajax Using TG (Score:1)
(http://www.hauntedspaceship.org/)
Off Topic (Score:3, Interesting)
(Last Journal: Saturday February 25 2006, @11:02PM)
I noticed all the stories have very few comments modded to 3 or above. And by few I mean 20. Just skip through any of the articles on the front page.
Did I not get the memo?
Too bad they didn't use Ruby on Rails... (Score:2)
(http://tomcopeland.blogs.com/)
I'm using AJAX a fair bit (mostly on the admin pages) on getindi [getindi.com]; it's very handy stuff!
Combine both.... (Score:1)
that word, are you sure you are using it correctly (Score:1)
(Last Journal: Tuesday June 24 2003, @03:33AM)
but, but, I remember imagining it. I remember it all over the tech press... and those guys that wrote the technology, they -imagined- it! For GOD'S SAKE WE ALL IMAGINE THAT SHIT!!!!
Yet Another Buzzword (Score:2)
All "Ajax" means is that Javascript now works. I used to accomplish the same tasks (i.e. asynchronously send/receive bits of data, dynamically update tables without refreshing the whole page) using hidden frames and javascript submits back in 1999. Javascript now has built-in functions to do this so it's less of a hack, but I don't think that it merits a whole new buzzword.
Then again, I guess it's something for new startups to tout and investors to latch on to, so maybe it's more of a business/marketing buzzword than a software/technology buzzword.
I don't want to "leverage" it (Score:2)
(http://tpno-co.org/)
Damn marketing driods
I've read this book and... (Score:2, Informative)
(http://www.kygeek.com/blog/)
OK book (Score:5, Informative)
(http://listeningtoreason.blogspot.com/)
If you use Java, great. But the book title is misleading, and it should be called "Foundations of Ajax in JavaScript and Java."
The other caveat: the book is designed for people who want to use Ajax to spruce up an existing web page a little, not design new applications built from the ground up to use Ajax as the data transport mechanism. If this meets your needs, great. If you're looking to do bigger stuff, get "Ajax in Action" froom Manning.
Gecko DOM Reference (Score:2)
(http://slashdot.org/)
AJAX? that some new thing? (Score:2)
(Last Journal: Tuesday February 24 2004, @06:10PM)
Is it good or is it wack?
Unimaginable? (Score:2)
DOM (Score:2)
(http://www.zone81.com/)
"New" and "exciting", eh? (Score:2)
(http://severinghaus.org/)
If that's what it comes to, why not just stick with Flash? At least with Flash, it doesn't take a dozen images and pages of CSS to effect a rounded rectangle! (This may be an exaggeration!)
JsUnit and AJAX don't mix! (Score:3, Informative)
(http://www.theblackforge.net/)
As I'm sure you all know, testing AJAX stuff in multiple browsers is really important if you want to guarantee cross-browser compatibility; it's also really tedious. JsUnit seemed like it would be a promising tool for AJAX automation.
In fact, I'm sad to say, JsUnit can't be used to validate AJAX components at all; in fact, it can't it be used to validate *any* command that requires a callback, including XmlHttpRequest, event handlers, pop-up windows, etc.
This is because browsers (IE/Firefox both) interpret JavaScript in a single thread, but actions you perform may have asynchronous side effects OUTSIDE of your own thread. So when you attempt one of those fancy asynchronous XmlHttpRequests, you can't just sleep/wait until your request finishes, because it will *never* finish until you completely return from your current thread. Only then will the interpreter begin working on the next item in the event queue.
That means, among other things, that it's impossible to wrap an AJAX request in a "try/catch" block:Because this will never work, JsUnit's strategy of emulating JUnit or the other *Unit frameworks is fundamentally unsuitable for testing AJAX in multiple browsers.
If you *are* interested in testing AJAX applications in multiple browsers, I recommend looking into Selenium [openqa.org], which basically works around the problem by constantly scheduling timers to re-invoke itself every 10ms... that gives the interpreter enough time to do other work, and allows Selenium to implement a simple "pause" action that actually works.
Ajax is not always great! (Score:1)
(Last Journal: Sunday March 21 2004, @06:47AM)
Unimaginable? (Score:2)
Wha? I happily admit that we've seen some pretty cool uses of the available technology in recent times, but I've personally been doing what is now known as Ajax for at least 5 years.
Would people please stop taking all the fun arcane stuff and wrapping up in media-friendly (and code monkey friendly) parcels?
Now a good chunk of my fun work will be replaced by some company's "Ajax Framework", just like web services and HTTP replaced roll-your-own network protocols, and Windows replaced custom GUIs.
Re:Ajax is suboptimal (Score:2)
(http://decafbad.net/ | Last Journal: Wednesday April 05 2006, @04:17PM)
Re:Ajax is suboptimal (Score:2)
Your premise - that developing Ajax web applications is harder than developing Flash applications - doesn't support your conclusion - that Flash is technically better.
You are assuming that Ajax web applications and Flash applications are of a similar quality - they are not. Flash applications are essentially executables that you are handed, with no choice but to run them or not run them. Web applications are documents linked together, with stylesheets to suggest a presentation and script to suggest an interaction model.
These two approaches are totally different. As a user-agent not only understands the final product, but the individual components that a web application is comprised of, it has much better opportunity to work with those components. This means that browser features that users are used to and expect to work do not break. There's a wide range of browser features that are broken in Flash applications that are not (necessarily) broken in Ajax web applications:
If you think that it's easier to develop something in Flash, then fine. But don't pretend that what you end up with is of equal quality. You end up with something very different to a web application, so whether the quality is higher or lower depends on your particular circumstances, and cannot be generalised to the extent that you do.
Re:If AJAX is so amazing... (Score:2)
Re:If AJAX is so amazing... (Score:2)
(http://www.creimer.ws/ | Last Journal: Friday January 26 2007, @12:40PM)
Re:Ajax is suboptimal (Score:2)
If I were to be given a choice, I'd develop in Flash over "AJAX" any day. No issues with browser sniffing, cross-browser glitches, or the debugging hell that comes bundled with complex javascript apps. But there are some things you can do with javascript that you simply cannot do with Flash. And there are degrees of "AJAX" - in a number of my sites I've used a single call to XmlHTTPRequest to send data contained in a page to the server without changing the page the user is on. Trying to fulfil that requirement by redeveloping the whole site in Flash is overkill.
Re:Hmm, what worries me (Score:1)
(http://www.kgreene.com/)
Incidentally, you are correct in that AJAX allows you to move a signifigant portion of your logic to the server and avoid some javascripts shortcomings.
Re:Ajax is suboptimal (Score:1)
(http://www.set.rmit.edu.au/~e24908)
Re:"What is AJAX" for beginners (Score:1)
Re:Issues with AJAX (Score:1)
(Last Journal: Friday October 19, @09:21PM)
Re:Chinese pee (Score:1)
(Last Journal: Tuesday May 03 2005, @09:38PM)
So then what does Chinese Pi taste like?
Re:Save $5.60! (Score:2)
(http://concurrentthinking.blogspot.com/)
Muchos gracias.
And if you use the "secret" A9.com discount [amazon.com], you can save an extra 1.57%!
Appreciated, but...
from A9: You can save an additional 1.57% (/2%) on virtually all your purchases at Amazon.com by simply becoming a regular user of our search engine at A9.com and on A9.com. Once you use A9.com for a few days you will be eligible for the A9 Instant Reward.
I'm not so easily bribed... at least not for a measily 1.57%. And even if I was, the patheticness factor of this 'marketing' scheme would outweigh the savings anyway.