ASPit - Totally ASP JSit - Totally JavaScript
Search PHPit

Use this textbox to search for articles on PHPit. Seperate keywords with a space.

Advertisements

Book Review: AJAX and PHP: Building Responsive Web Applications

(Page 2 out of 2)

In chapter two there's more theory on topics like JavaScript, the JavaScript DOM model, the XmlHttpRequest object and XML. These topics are thoroughly explained, with examples to demonstrate how they work. The XmlHttpRequest object is covered very in-depth, and the book takes a good look at the different "types" of the object, namely the native object in Firefox/Opera/Safari and the ActiveX object in IE. Something I didn't know is that IE actually comes with different versions of the XmlHttpRequest object, and the book shows you how to use the latest version (which supposedly comes with more features). Another good thing about chapter two is that it immediately looks at using XML in your AJAX requests ("putting the X in AJAX"), and it also shows you how to handle invalid XML in JavaScript by using various tricks. This is really useful information, because you can't catch invalid XML using standard JavaScript error handling (try {} catch).

In chapter three you are introduced to the server side part of AJAX. You will learn how to use PHP's inbuilt DOM functions to create an XML response for the AJAX request. Although this technique works fine, I've never done it like this myself, and I find it much easier to first create a standard PHP array of my data, and then to transform it into standard XML using a XML_Serializer. Each to his own of course, but the DOM method needs more code than my method. The book also shows you how to use a custom error handler (with the set_error_handler() function) to catch any PHP errors, and send it back as an XML response. This is really quite an important step, especially during development, since you won't be able to see the errors when they're printed (like a normal PHP script).

Chapter four is the first example chapter, and marks the end for most of the theory. In this chapter you take a look at form validation, and how AJAX can be helpful. Most of the chapter is spent on building a simple form validation script, and explaining the script, but this chapter also explains how to build thread-safe AJAX. Since AJAX is usually asynchronous, it can often lead to requests coming back in different order than they were sent. To learn more about this problem, have a look at "Troubles with Asynchronous Ajax Requests and PHP Sessions", but in some cases it's important that requests come back in the same order. This book will show you exactly how to do this.

In chapters 5, 6, 7, 8, 9 and 10 you are taken through more examples, like an AJAX chat, color picker, dynamic images with SVG and AJAX, an AJAX RSS reader, and more. All these chapters are pretty much about these examples and explaining them, and you won't really learn anymore new theory about AXAX itself, but these chapters do introduce a few other new topics, like using XSL to transform XML or using SVG.

Final Verdict

Although I've done countless of things with AJAX myself, and have a firm grasp on how it works, I still learnt a thing or two from this book. Most of the stuff was common knowledge for me, but there were still a few new things. If you're an absolute beginner when it comes to AJAX, and want to get started, I can definitely recommend this book. It starts off with the basics and slowly moves towards the more difficult stuff.

One thing I missed in this book was the usage of JSON. It's briefly mentioned in the beginning of the book, but an example of how it's used is never given, even though JSON is so much easier to use than XML. Another thing I was hoping to see was a bit more information on the current state of AJAX/PHP libraries, like SAJAX and My-BIC.

All in all I'd say this is an excellent book, and well worth reading and keeping as reference. It's not too long either, since the last seven chapters go really fast. Highly recommended.

« Previous: Part One



7 Responses to “Book Review: AJAX and PHP: Building Responsive Web Applications”

  1. Cristian Darie Says:

    Dennis, thanks very much for reviewing my book! I’ve mentioned in the book’s page on my website.

    Regards

    Cristian

  2. srinivas gourishetty Says:

    Hello,
    thanks for review,

    Christian Darie,
    can you send me a pdf version of this book please,
    i want to go through this book,
    and i will leave a review of this book on my site www.getphpsupport.com

    in fact, i want to make my whole site using php and AJAX,
    so if you can share it with me, i will be helpful,

    if you want to contact me,
    you can at successlieswithme-somethingxy.com
    please replace -sometingxy with @

    thank you

  3. srinivas gourishetty Says:

    sorry,
    replacde -somethingxy with @gmail
    thank you

  4. Cristian Darie Says:

    Hello,

    Just wanted to let you know that we’ve made a step ahead by covering JSON, in a new version of Chapter 5: AJAX Chat. The PDF version of this new chapter is available for free download on my website at http://www.cristiandarie.ro/ajax-php/

    Thanks!

    Cristian

  5. Tessa Says:

    Thanks Cristian. Covering JSON was a great move (especially as I’m still wondering what the big-deal vs. XML with it is) I’ve downloaded the free chapter and I’ll re-implement my Chat experiment using it.

    FYI: I just reviewed this book myself and now that I’m looking for other little venues to update and post regarding it, I’m seeing a lot of the other reviews and can see we’re all on the same boat with the book. You guys did a good job, and thanks so much Cristian, for handling the errata data and new chapter updates on your site.

  6. Cristian Darie Says:

    Tessa, thanks very much for the kind words, and for the wonderful review!

  7. Boycott Earth Says:

    Ajax Book Report!!

    Ajax is quickly changing the way we visit and how we interact with websites. It is about time. I have done my fair share of technical book reading. I have advanced from the Dummies series over the years to the more advanced O’Reilly series. My p…

Leave a Reply

About the author
Dennis Pallett is the main contributor to PHPit. He owns several websites, including ASPit and Chill2Music. He is currently still studying.
Article Index
  1. Part One
  2. Part Two
Bookmark Article
Download Article
PDF
Download this article as a PDF file