This article is more than 1 year old

Ajax Hacks

Playing with AJAX

Book review Everybody loves Ajax. Javaists, Rubyists, Pythonistas; even Microsofties get to play with Ajax in the form of Atlas. Book publishers love Ajax too, judging by the stack of new titles coming hot off the presses.

O'Reilly has added to the pile with a new title in their long-running "Hacks" series. The aim of the series is to present developers with a series of hacks, tricks, tips and gee-whiz moments. Think of it as a good place to dip-in for ideas, examples and code that can be lifted and re-worked for your own projects. Each book presents a numbered sequence of these "hacks", organised thematically so that readers can easily home in on the topics they're interested in.

With a relatively new technology like Ajax there are going to be many readers picking the book up with little prior knowledge or understanding of how it all works. Therefore, the first chapter of the book is devoted to explaining how Ajax implements asynchronous communication between the browser and server, and where JavaScript and XML fit into all this. It discusses the document object model, browser incompatibilities, alternatives to XML (in the form of JSON) and so on. In short, you have all the elements of an introductory tutorial; however, it is broken up into a sequence of "hacks" – which is a structure that doesn't really work in this case.

The next two chapters – web forms and field validation – are also largely tutorial in nature. They pick up from the basics and present code to actually do some useful bits and pieces for creating forms and validating fields on the fly. It's at this point that the appeal of Ajax really becomes clear – no more having to round-trip to the server to check that users have entered valid credit card details, email addresses etc.

The gee-whiz element really kicks in with chapter four's collection of mash-up hacks for dynamically aggregating content from Google, Yahoo and other sites. Where novice Ajax programmers will find the first few chapters most useful, it's here that more experienced developers are likely to get excited.

From then on, the book focuses on some of the other technologies and libraries that work with Ajax. The first of these is the DWR (direct web remoting), which enables Java developers to easily map between Java objects on the server and JavaScript code on the client side. Ruby developers shouldn't feel left out as they get a chapter on using Ruby on Rails with Ajax. And for JavaScript there are chapters that look at Rico, Prototype and the script.aculo.us libraries.

The final chapter looks at some of the more thorny issues that Ajax applications have to deal with. For example, what does the back button do when your application is hosted pretty much on a single web page? In a data-heavy application, hitting the back button could cost your users a lot of lost work. This and other deployment issues get hacks devoted to them in this closing chapter.

While there's a lot to commend the book, there are a couple of things to note. The first is that this is clearly not the best book for someone wanting to learn Ajax from scratch. Ajax In Action (reviewed here), provides a more thorough grounding. Secondly, this is a fast moving area of software development with new tools, techniques, and libraries emerging all the time, so there's something of a timeliness issue to bear in mind.

Ajax Hacks

Verdict: While not the ideal beginner's book, it has some good ideas and is designed to appeal to a range of developers wanting to get in on some Ajax action.

Author: Bruce Perry

Publisher: O’Reilly

ISBN: 0596101694

Media: Book

List Price: £20.99

Buy this book at Register Books, at Reg Developer's special discounted price. ®

More about

TIP US OFF

Send us news


Other stories you might like