Professional Ajax

8 comments | Posted: 21 March 06 in Books, by Nathan Smith

Professional Ajax Last month, I was contacted by Wrox Press asking me to review one of their latest books, Professional Ajax. I of course jumped at the opportunity, and have found this to be a very well rounded guide to Ajax technologies. It serves not only a comprehensive overview of all the various methods for handing complex asynchronous information exchange, but is also a handy reference guide for creating highly sought after effects for integration in your own site projects.

In case you didn’t already know, Ajax itself was a term coined by Jesse James Garrett in an article he wrote for Adaptive Path in February of 2005. It simply stands for Asynchronous JavaScript And XML. A little over a year later, and the entire web is abuzz with the new terminology. I was even able to attend a panel at SXSW on Ajax, led by Jesse himself. People just can’t seem to get enough!

Aside from JavaScript, it is important to realize that this mantra is less about a specific language and more about a method of user experience enhancement. The authors of this book, Nicholas C. Zakas, Jeremy McPeak and Joe Fawcett do a good job of staying platform neutral and language agnostic. They cover a myriad of examples with PHP, Java and the Microsoft .NET platform.

They start out with a brief history, and show how the logic behind Ajax has evolved from framesets to iframes, and now the popular XMLHttpRequest. Since this is not an official W3C standard, a small bit of code forking is necessary. Most modern browsers handle it the same way, but Internet Explorer still treats it as an ActiveXObject. However, this change is slated with the release of IE7.

Since I’m already pretty familiar with the theories behind Ajax, the chapters that stood out to me the most were 6, 7 and 8. Chapter six was devoted to web services, covering SOAP, WSDL and REST. It also shows how to make a rudimentary browser calculator, and a spell checker using the Google API.

Chapter seven focused pretty exclusively on JSON, a lightweight alternative to using XML for asynchrounous data transmission. XML is argued to be more human readable, but since this information is created to be parsed and not read, the proponents of JSON prefer the lighter file size and ease of use. By way of example, here is some XML code, as compared with its equivalent in JSON. These brief code snippets originally appeared on pages 195-6…

XML:

<classInfo>
  <students>
    <student>
      <name>Michael Smith</name>
      <average>99.5</average>
      <age>17</age>
      <graduating>true</graduating>
    </student>
    <student>
      <name>Steve Johnson</name>
      <average>34.87</average>
      <age>17</age>
      <graduating>false</graduating>
    </student>
    <student>
      <name>Rebecca Young</name>
      <average>89.6</average>
      <age>18</age>
      <graduating>true</graduating>
    </student>
  </students>
</classInfo>

JSON:

{ "classInfo" :
  {
    "students" : [
      {
        "name" : "Michael Smith",
        "average" : 99.5,
        "age" : 17,
        "graduating" : true
      }
      {
        "name" : "Steve Johnson",
        "average" : 34.87,
        "age" : 17,
        "graduating" : false
      }
      {
        "name" : "Rebecca Young",
        "average" : 89.6,
        "age" : 18,
        "graduating" : true
      }
    ]
  }
}

As you can see in the above example, JSON is a lot more concise and more lightweight in terms of file size. The drawbacks of using JSON over XML are that there is not native support for it in any languages other than JavaScript, as it’s a code variant and not a markup language. So, some content transformation is involved in making use of it. An additional benefit of XML is that Flash can parse it natively more easily, as of version 8. It’s really just based on preference.

Using JSON, they teach how to recreate Google’s popular auto-suggest feature, which completes possible search terms as you type. Chapter eight is where things really start to get fun though, because they teach you how to make even more web-based widgets. These include an animated news ticker, a weather checker, and a localized website search engine using a few external API’s.

The whole of chapter nine is devoted to constructing a web-based POP3 email application that mimicks the functionality of Gmail, including the courtesy of keeping the browser’s Back and Forward buttons working normally. Chapter ten finishes off the book nicely by covering some popular Ajax frameworks, such as JPSpan for PHP, DWR for Java SDK and Ajax.NET for the .NET platform. Bascially, if you want to really delve into Ajax concepts, this book is ideal.

Discuss This Topic

  1. 1 Yannick

    Been recently toying with the idea of using AJAX for some projects for work, so this book just might come in handy at some point.

    Nathan, would you say this book is a good one for beginners? Or more for people who have an intermediate grasp of the concepts already?

     
  2. 2 Ben Otero

    Out of curiosity, how would you say this book stacks up with the likes of Foundations of AJAX? I’m thinking of picking up a book on the topic, and with some experience using AJAX already, I don’t want to get one that primarily covers what you could learn in a few online tutorials.

     
  3. 3 Nathan Smith

    Ben: I would say that Professional Ajax is the next step up from the more introductory Foundations of Ajax. They’re by different publishers of course, and as such aren’t meant to be building blocks, but I think it’s safe to say that this book will give you a more complete understanding, with real-world examples. Professional is a good deal longer than Foundations, 406 versus 296 pages.

     
  4. 4 Robert

    Sounds like a good book! For those who are interested in picking up an AJAX book I suggest taking a look at this one first before you decide what book to buy.

    I have the beta book and it is an awesome read thus far. Very informative, taking a beginner on the journey to becoming a professional.

    What I found initially interesting is that the authors make the claim that Google maps is not really proper AJAX because it does not take advantage of the modern asynchronous callback technology.

     
  5. 5 Ben Otero

    Nathan, Robert: Thanks for the info and suggestions. I plan on reading up more on these along with getting a better handle on XML for use in a web app I’m brainstorming now.

     
  6. 6 Nathan Smith

    Ben, sure thing. I will also be reviewing another Ajax book in the next few weeks or so, entitled AJAX and PHP: Building Responsive Web Applications. I’m looking forward to it, because I’m not a real big ASP or Java guy, focusing mainly on PHP, with the rest of my attention on front-end code and design.

     
  7. 7 Brian

    JSON is incredible. We’re using it to do some very cool things.

    Excellent review.

     
  8. 8 Nathan Smith

    Thanks Bryan. I agree, JSON looks like it has huge potential / application. I was blown away by how much more simple and lightweight it is, compared to XML.

     

Comments closed after 2 weeks.