Chapter 6. More Than Words Can Say


But I'm so much more than just a pretty face... I really do have something to say.

Ever feel like nobody is listening to you? Sometimes plain old English just doesn't cut it when you're trying to communicate. You've been using text for all of your requests and responses so far, but it's time to break out of our plain-text shells. In this chapter, we'll dive into XML, and teach our servers to say a lot more than they ever could with plain text. As if that's not enough, you'll teach your requests XML, too, even though that's not always a good idea (more on that inside). Get ready... once you've finished this chapter, your requests and responses will never be the same.

So vat is on your mind zees week, Meester Server?

I just don't feel like anyone wants to listen to me.

Dr. Zigmund: Ahhh, yes. So many of my patients feel zees way. It is a common problem. But in many cases, it is zimply just in your mind.

Server: But in my case, it's true! I mean, everyone wants to talk to me... I've got plenty of people saying things to me all the time...

Dr. Zigmund: Zee? Zat is very important, to have friends that are zere for you.

Server: But that's the thing. When I start to say something back, they barely listen. In fact, it's been getting a lot worse just lately.

Dr. Zigmund: Tell me more about... "lately."

Server: Well, I used to say a lot of things. Like <html><head><title>Hello!</ title></head></html>. But now, if I say anything more than "1012", I get complaints. Nobody will let me get more than a word or two into a conversation.

Dr. Zigmund: And you zay you have more to zay?

Server: Yes! I have much more to zay... I mean, say. Sometimes, I have a lot of things to say. I listen all the time and I never ignore a request... but when it comes time for me to respond, if I'm not done in a second or two, I get called these horrible things...

Dr. Zigmund: Like what? What do zey call you?

Server: Slow... bloated... 20th-century... oh, it's horrible! I just want people to let me say a little more than "6" or "Pot 1", you know?

Speak Up!

Time for a quick refresher on what the server's been saying to our Ajax apps. Below are the five example applications you've developed so far. Your job is to go back and figure out what the server responded within each app, and write that response on the lines provided.

Chapter 1: Boards 'R' Us

Chapter 2: Break Neck Pizza

Chapter 3: Ajax Coffee Maker

Chapter 4: Top 5 CDs

Chapter 5: Break Neck Revisited

So did the server have much to say? What about all these complaints about nobody listening? Do you think they're valid? Check your answers below, and decide for yourself... is the server getting to say very much?

Chapter 1: Boards 'R' Us

This is the only app where the server gets to send much back...

Doug Henderson 7804 Jumping Hill Lane Dallas, Texas 75218

Wow... the server really doesn't get to say much in these apps.

Chapter 2: Break Neck Pizza

Chapter 3: Ajax Coffee Maker

No ser ver involved!

Chapter 4: Top 5 CDs

Remember, this was how long it would take for the pizza to arrive.

Chapter 5: Break Neck Revisited


Do you see what I mean? I can't go on saying nothing more than "7", or "2"! It's driving me insane!

Dr. Zigmund: Vell.... I do zee that you got to zay quite a bit in zee Chapter 2 over there. A whole address... zurely that's ex-ziting!

Server: Well, yes, but that's still just one thing. I mean, I couldn't send back, say, the customer's address, and a special coupon for repeat customers. I just get to say that one thing: their address.

Dr. Zigmund: Vell, zey zay that brevity is the zoul of wit.

Server: What? Oh... the soul of wit. Well, whoever "zey" are, they don't have to sit around all day listening to long requests, now do "zey"?

Dr. Zigmund: Now let's just calm down. Have you tried to say more than one thing in your responses?

Server: Sure! But nobody really understands what I mean. Like, once I tried to send a customer's address, phone number, and order back, and I used a semicolon to separate each part of my response. But nobody seemed to like that... they said I was too "proprietary", and that I needed to be "standardized." Dr. Zigmund: Zat is true, you know. Next, you'll tell me you were using commas or zat strange "pipe" symbol to split your data up.

Server: (Well, there was this one time...)

Dr. Zigmund: I think I have just the zing for you, my dear friend. Let me just get out my prescription pad. It's time you got a good dose of zandardization. Zis will help everyone under-zand exactly what you're saying.

Server: What goes is zander... ummm... standardization going to do me? I just want to be understood...

Here's the prescription that Dr. Zigmund wrote out for Server.




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