Relevance Review #6: Ajax for Dummies

Ajax for Dummies, by Steve Holzner

Quick Summary: Very basic, uneven, a few painful errors. If you are looking for a very basic introduction, try Head Rush Ajax instead.

Albert Einstein famously said "Make everything as simple as possible, but no simpler." Ajax for Dummies tries to make Ajax too simple. As a result, the presentation is uneven, spending tons of time on really basic stuff, then darting past important complexities. In the first third of the book, truly basic questions are painstakingly answered:

  • What is an if statement?
  • What are variables?
  • What are browser events?

More complex concepts, necessary to understanding the examples, get minimal treatment later on. A few examples:

  • JSON is used in a few places but never identified or explained. (The sample code often creates multi-object arrays one line at a time.)
  • Objects, constructors, this, etc. get one paragraph.
  • Closures (not named as such) are explained in less text than the if statement gets.
  • The difference between false, undefined and null is never explained. (Judging from the source code, the author is not clear about the difference.)
  • JavaScript prototype is not explained (and is not a term in the index).

The other major concern with this book is the technical errors. I didn't spot many, but the few were significant.

  • On the difference between GET and POST (p.106): "if you use ... the GET method, your data is pretty public. As it zings around the Internet, it could conceivably be read by others. You can protect against that by using the POST method instead of GET". This is wrong in what it says, and in what it misses. (Google for "GET VS POST")
  • More GET abuse: The drag-and-drop example (p.192) shows you how to use GET to update a user's shopping cart.

The commitment to "wishing it simple" produces some misleading advice. With regard to code-centric Ajax, the author says (p. 114):

I'm not really an advocate of using JavaScript sent to you from the server in Ajax applications, except in one case -- if the server you're dealing with you gives you no choice.

He then proceeds to build an example that connects to Google Suggest, which returns its data as script. The reader is left to wonder why Google sends back script. Weren't they "dummies" enough to follow the author's advice? What the author doesn't know, or at least isn't telling the reader, is that the Google Suggest API is designed to support the dynamic script tag technique for cross-domain access without a server proxy. More realistic advice to the reader would be this:

(Hypothetical) The issues around whether and when you should use code-centric Ajax are far too advanced for this book, but here's how to do it anyway. P.S. Here's a loaded pistol; now go play outside.

Wrapup:Ajax is not for dummies.