Head Rush Ajax. Brett McLaughlin. 2006
'Get it in your brain fast'
Ajax, the new wonderkid of the web? In fact a grouping of existing technologies, it has been possible for quite some time. Bringing 'interactivity' to XHTML pages through javascript calls to backend scripts. The javascript takes input from the front end web application, send xml requests to the backend, then displays returned results on the front end using DOM scripting.
Head Rush Ajax is a 'learner' book designed to help you pick up Ajax quickly and retain that knowledge. My own slant on the book was coloured by having already written some Ajax functions on sites, and wanting to recap, consolidate, and find out bits of knowledge I may have missed when picking up Ajax through surfing the web.
I read the first 100 pages of the book in 1/2 hour on a crowded train which shows how quickly and easily the book can be read. In 100 pages it explained the core concepts of making Ajax calls through javascript. The material treatment is ludicrously patronising to the point of being more entertaining than insulting. The style however kept me at the book, reading it all in two hours, so I don't think the way it is written is necessarily all bad. It was so fast to read, that although it took 100 pages to explain 20 lines of core Ajax code I didn't feel I was wasting my time.
The book expects the reader to know HTML, CSS and javascript. No backend scripting knowledge is required though. In my mind however, it is not possible to successfully write Ajax without writing front and backend code. The idea that a developer would write the back end, and a designer (?) the front end seems unlikely, through some agencies may do this.
The principle aim of Ajax is to offer greater interactivity, refreshing part of the page instead of all of it as with normal page loads. This approach has caused accessibility experts to raise strong concerns about Ajax and people such as the WCAG group are struggling to make recommendations on Ajax to allow it to be used by all users successfully. Additionally because Ajax relies heavily on javascript, while core browsers may support the Ajax javascript, with the explosion of non PC/Mac based browsers, many devices do not support javascript sufficiently to allow Ajax functionality to work on them. The guidelines given therefore when using Ajax by accessibility experts are that Ajax should be built as an additional layer on top of a fully functional site, so that if the Ajax (javascript) is turned off or fails, the site should still be usable. The Head Rush book makes no discussion of these concerns, presumably because it considers these issues to be above the beginner level it caters for. These issues are so crucial to the development of sites built to web standards that this is a major omission in the book.
Back to what the book does discuss:
- the Ajax mechanism as outlined above
- creating the XML request object that works in different major browsers
- javascript event handling to track user input and make the information request
- it describes in straightforward terms why Ajax is asynchronous through an example
- capture of the servers response to a handler callback function with use of the requests ready state and return status (200 if successful).
- the use of DOM scripting to get user input and writing output to the pages DOM
- how to choose when to use 'get' or 'post' requests
- problems with browser caching when using get requests
- separation of javascript code from html to keep behaviour logic separate from presentation (css) and content (HTML).
- it provides some simple javascript libraries for reading and writing text nodes in the DOM
- sending and handling multiple simultaneous Ajax requests
- there is a description of the DOM (Document Object Model), but I am not convinced that this was very clear, and how to move around the DOM tree using javascript.
- how post can be used to send more data than get, setting content types for url encoded (name and value pairs), and xml for more complex data.
- an ambitious description of SQL injection, normally solved through front and backend validation and use of parameterised queries. Primarily this is tackled using backend code, but the book focuses largely on frontend code and it is difficult to see how useful this discussion is, as the book looks at backend code quite sketchily. I was glad to see SQL injection mentioned in the book however.
- xml structure and parsing of a returned xml document from the backend
- a comparison of XML and JSON - a newer more lightweight transfer format based on javascript
- brief use of Ajax toolkits mentioning prototype, dojo, script.aculo.us and rico
- DOM inspection using IE DOM inspector and Safari webkit
- the code from the book, some at www.headfirstlabs.com
The book covered a lot of ground in a lightweight but entertaining way that may help non developers pick up the subject. It doesn't alienate developers though, as its approach allows them to quickly digest areas of knowledge they wish to pick up on. I am not sure that it would represent good value for money for the latter however.



