Chapter 7. A Fight to the Finish


It's time to go back to elementary school. Remember the days when differences were resolved with harsh words, flying fists, and poor kung fu imitations? Remember when nothing thrilled your soul like hearing "Fight!" screamed in the halls of the cafeteria? In this chapter, we're going back to those days, and leaving friendly words and the golden rule behind. XML and JSON, two different formats for sending and receiving data in your asynchronous requests, are ready to let their differences be settled in the squared circle. Get your scorecard ready, and let's take it to the ring!

Hey Frank, look at this... I found this great article about a new data format that works with asynchronous apps. It's called JSON, and I really think we should check it out.

Frank's a PHP guru, and has been helping us by writing all of our PHP scripts throughout most of the book.

Joe's not much for server-side programming, but he loves JavaScript.

Frank: Why do we need a new data format? Since we went to XML, I think things are running better than ever.

Joe: Well, maybe for you. But XML isn't exactly easy to work with for us JavaScript guys.

Frank: Why not? I thought that you were using the Document Object Model to handle the XML my scripts have been sending back to your requests.

Joe: Well, yeah, I have been...

Frank: Yeah, I saw that Top 5 CDs app you wrote. It was sweet! And you only used the DOM? You must be pretty good with that thing...

Joe: Oh, I love the DOM for working with web pages.

But it's just a little clunky when it comes to XML. I mean, I spend all my time moving up and down the XML document just to get a few values out.

Frank: So you think this new data format will help? Tell me a bit more about it.

Joe: Well, it's called JSON: JavaScript Object Notation, and it's

Frank: Wait a second. The data format is JavaScript? That doesn't sound so good. I write PHP, Joe, not JavaScript! What are you thinking?

Joe: But it's supposed to be really easy to use, and fast...

Frank: Look, I'm a server-side guy. I'm not gonna start using JavaScript in my PHP. That's just nuts!




Head Rush Ajax
Head Rush Ajax (Head First)
ISBN: 0596102259
EAN: 2147483647
Year: 2004
Pages: 241

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net