Foundations of Ajax
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.
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.
Not even one mention of "Web 2.0"!
could someone kindly link a page that demos ajax's features?
While I appreciate this review, is the book really neccessary? AJAX moves very quickly, with new/better examples popping up everyday. Maybe it's me but I find less of a need for technical books and magazines since I can get all of my information from the internet. The personal example I'll use is Sys Admin; great magazine but I haven't leanred much from it during the last year. If I want to learn a specific server app or hack it's just easier and more up to date to grep it online.
fak3r.com
So, is there an IDE like Visual Studio for AJAX, or are we expected to wade through pages of HTML and Javascript like in the old days of the web? In my opinion, GUI applications are best developed inside GUI applications.
Religion for nerds. Stuff that really matters
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.
I know PHP/Javascript/HTML relitivly well. Do you think this book would be an easy read for me. Or would I really have to sit down and try. Heh, got the book for christmas and just looking for time to read it.
np
45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
"Practically every new and exciting application on the web uses some form of Ajax"
There are new and exciting apps on the web? Wow must have missed them.
Chinese pee tastes like math.
why doesn't Slashdot use it? Eh??
I have actually read/worked through this book and indeed it was not only one of the first books on Ajax but also one of the better books on Ajax. Some of the portions are now a little outdated, like the discussion on frameworks, but these areas can easily be filled in with a little research on the Internet.
FREE - Java, J2EE and Ajax Audiobooks for Software Developers - www.DeveloperAdvantage.com
I personally, use Comet, but only because it has a cool song
Oh, that Ajax.
Nevermind...
The lumber industry, paper mills, and O'Reilly publishing are all it together! Create a new programming language and Presto! More revenue for all!
Saturday is April 1. Slashdot will be shut down. Sorry for the inconvenience.
Like, this one, perhaps.
Some of you might be interested in a recent Presentation / Screencast given by Kevin Dangoor (creator of the TurboGears Python web framework) given at this year's Pycon. Although he does talk a bit about TurboGears, most of the talk is tips and examples on how to add functionality using Ajax without confusing users.
would say those pages use AJAX. Most of the people involved in coding the sites listed are probably not lame enough to use that term. They probably just call their collective code a "web site" just like the rest of us who are sane (or insane but still coherent enough to despise the terms AJAX and Web 2.0) would call it! That's what we get for letting mcse's become "programmers"... sigh. Welcome to IT Hell 2.0.
Save yourself $5.60 by buying the book here: Foundations of Ajax. And if you use the "secret" A9.com discount, you can save an extra 1.57%!
But is something going on with the moderator points? Or is it just a slow day (or three)?
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?
[Fuck Beta]
o0t!
...InstantRails makes it easy to get it up and running, and Rails definitely has AJAX support built in.
I'm using AJAX a fair bit (mostly on the admin pages) on getindi; it's very handy stuff!
The Army reading list
I would like to see an application that can work online and offline with same ease. We, at my firm, had tried an app using java which worked standalone when network was loaded and became online when there was less congestion. Our internal network was so slow that the application was standalone most of the time. That was India and year was 2000. Now Ajax looks like a good solution for a long forgotten problem.
"... deliver content in ways unimaginable only a few short years ago"
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!!!!
-pyrrho
There is supposedly going to be an eclipse plugin. http://www.eclipse.org/proposals/atf/
Posting anonymously since it's about my work; I've moved from doing Javascript in the late 90's early 2000's to working with Flash, and now recently back to mostly Javascript with the Ajax market boom. The reason I moved to Flash in the first place is more clear now than ever. The "Browser" ad hoc platform is horrible to develop for compared to Flash.
Inconsistent support for "Standards" across browsers, weak development tools, and worse support for Accessibility all make Ajax a freakshow. Flash is a bigger more consistent platform (more people have Flash than Ajax capable browsers) with good tools. There are Open Source Flash dev tools, but the Adobe ones are good enough to rapidly earn their cost back in productivity gains.
I understand that people are excited about Ajax, Google's apps are cool, but the fact that this excitement never translated to Flash, which has had similar cross-platform capabilities for about 5 years now shows that technological decisions aren't made on a technical basis alone.
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.
There are 2 kinds of people in this world. Those that can keep their train of thought,
Someday we may even be able to open whole applications and graphically view them on a remote terminal!!!! The past is the future can you say X-windows?
I want to use it.
Damn marketing driods
Mod me down with all of your hatred and your journey towards the dark side will be complete!
I picked this book up on my last trip to Vegas. I read it cover to cover. I found it to be on the elemtary side of the AJAX discussion. I was disappointed when I found most of the content, code examples and demos can be found online in different places. AJAX is just a hot topic right now, I find this book as an attempt to ride the coat tails of the AJAX phenom.
I have this book. It's a pretty straightforward introduction to the topic. The central problem with it is that all the examples that use server-side components only use Java.
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.
I also recommend that you check out the Gecko DOM Reference. It's a great, handy online resource which I've consulted frequently as of late for many DHTML apps and functionality.
I only post comments when someone on the internet is wrong.
Here is goes: AJAX is a techology, supported by some major sites (Mozilla, google, etc), which tries to counterpart Macromedia. Macromedia has been the best solution to dynamic content. It makes a GUI inside your browser. Netscape, google and a few others feel that Macromedia is becoming too powerful. So they are trying to come up with an alternative.
...), without competition. And thus you suck the ads. Keep up the hype.
That's why AJAX was made (and hyped so much). In Reality (TM), AJAX is nothing new. It is based on the crap language called Javascript (which is a huge succes because it is supported by all web browsers and as a result it's the most PORTABLE language of all times). XML, the other hyped technolody which is just an inefficient way to transfer data (but this is counterparted by the amazing JSON innovation). And "Asynchronous". "Asynchronous" means that your browser sends data (files, passwords) to the internet without synchron.
Ever wondered why Mozilla doesn't have a "turn off all ads" button?
Because it can afford being the only browser which can support all these crazy extensions (Web2.0, AJAX, css2.0, XHTML7.5,
How much does this book's approach to AJAX depend on writing Javascript? I have a good deal of experience with Javascript, and frankly, I'm sick of it. Javascript's constant browser incompatibilities are simply more than I can deal with. AJAX seems like it would allow one to avoid many of Javascript's problems by moving logic into the server, but it also seems like it is an invitation to have to write a program on the server side and then have to debug it at every step on four different browsers on two different operating systems. If AJAX suffers from the same compatibility hell I have seen with trying to write CGI with embedded javascript in the past, I am tempted to just wait to get into this AJAX thing until "rails" style libraries become robust enough that they generate browser-specific javascript for you.
I'm curious about this book, but to what extent must someone overcome crossbrowser javascript hell in this book's approach to AJAX? Is this material I would benefit from learning despite my acquired Javascript aversion?
Thanks.
Is it good or is it wack?
All's true that is mistrusted
You've no doubt heard about Ajax. Practically every new and exciting application on the web uses some form of Ajax.
Not this bullshit again!
Mods obviously have nothing better to do.
I'm thinking about investing a bit of time to learn one or two of these frameworks. Learning Ruby on Rails is pretty much a given just because of the mindshare it has. But I prefer Python over Ruby because of the vast array of libraries available for Python, so I also want to pick up a Python framework. Django and TurboGears seem to be the leading contenders. Can you tell me any reasons why I should pick one over the other? They both seem to be relativly new and under rapid development. Neither seems to be clearly ahead in the marketplace. Any reason to pick one over the other?
Too bad that "the source" is a very poorly structured website IMO where I can never find what I want. I guess I just didn't try hard enough, but I couldn't find a comparable page at W3 as the DOM index I linked at Mozilla.org. I don't want to know the fucking history, recommendations, all that bullshit. I want real information that I can take and use, right now. Where's the "pocket reference" pages?
Am I the only one who thinks it's difficult to use the W3 site as a general programmer's reference for anything at all? Whenever I think to myself, "Gee, I'd like to do this the right way, and conform to W3 'standards'", I get lost at W3 and go elsewhere for the Cliff's Notes version.
I only post comments when someone on the internet is wrong.
I think it is more like, when using AJAX, user interfaces are slowly creeping back up to where they were 10 years ago, before everything was crippled to work as a web form in the lowest common denominator browser. Web interfaces still have a hell of a long way to go before they are even close to the level of sophistication that rich clients were at 10+ years ago. Everything that is new was old once before.
Even really busy threads like the Vista wont suck had really few comments modded up. I think it has been just the last couple days too
Some very simple samples but with understandable code, just go to
http://wyoguide.sourceforge.net/test/tree1.html
http://wyoguide.sourceforge.net/test/tree2.html
http://wyoguide.sourceforge.net/test/tree3.html
http://wyoguide.sourceforge.net/test/tree4.html
try them out and view the source. For more info go to http://dojotoolkit.org/
O. Wyss
See http://wyoguide.sf.net/papers/Cross-platform.html
http://fuckweb2.com/
Dynamic Object Model!?
I code, therefore I am.
It is offtopic, but it is the first comment I've read wondering what is going on. I've noticed this as well. Have fewer users been given moderator status lately or something?
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!)
Steven N. Severinghaus
AJAX is nice and very handy. But I have already seen problems. Especially with Gmail. I replied to an e-mail message and clicked send. At the same time my Gmail notifier told me that there was network problems and Gmail just sat there with the red message up in the top "sending". After 10 minutes of waiting I clicked stop on the web browser and refreshed my In-box. The message showed up in the in-box but the actual message was never send and the recipient never received the e-mail. But ofcoz if they used Forms and CGI then it might never worked right either. Network issues will always exists, but can AJAX notice this and fail when it should?
[Fuck Beta]
o0t!
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, 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.
When I moderate, I only use "-1, Overrated". That way, I never get meta-moderated!
Sure, AJAX is great for certain applications and under certain conditions, but there are always a few downsides / problems. Check out the blog entry by Harry Fuecks for some links to good presentations describing the negative aspects of AJAX.
...but, unlike Ajax, Web 2.0 is not STD (Stronger Than Dirt!).
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.
I think that TG is all around more Pythonic than Django. It incorporates many different successful Python projects, whereas Django rolled their own (Templates, ORM, Controller, etc.). Not that that's a bad thing, but TG does enjoy quite a few benefits by building on other successful projects (more eyes looking over the code, more people interested, more developers). Also, the TurboGears development process was opened a lot earlier than Django, so there is more community involvement, more developers, and more activity, even though it has been around for less time.
Some of TG's key features like the Toolbox, Internationalization (adm18n), Model Designer / Browser, Identity, template plugins, etc. are a direct result of close community involvement. On the Django side, their "Magic Removal" branch is a result of late community involvement, which is only now "removing warts that Django has accumulated over the years". Similarly, Django devleopers have said their architecture is loosely coupled, but some things (e.g. the templating system) are still not easily swappable. TG definitely is designed to work closely with the main components, but some developers prefer different things, so there is a layer of support for different templates (Cheetah, Stan, ZPT, etc.), and recent work has been done to get an SQLAlchemy compatibility layer for people who don't like SQLObject.
Either way, 2006 will be the year of Python web frameworks (I would even go as far as saying that Python will leapfrog the RoR hype), with TG and Django both experiencing a lot of maturing as they reach 1.0 and beyond. Also, recent developments in WSGI and standardization between Python web frameworks means it will be easy to switch between Django/TG/etc and build apps out of reusable pieces, no matter what framework they were originally written in.