Section 3.1. What does asynchronous really mean?


3.1. What does asynchronous really mean?

Asynchronous means that you don't have to wait around while a web server is responding to your request. That means you're not stuck: you can go on doing what you want, and have the server let you know when it's finished with your request. Let's take a view of this from 10,000 feet by first looking at what a synchronous request is, and compare it to an asynchronous request.

3.1.1. A synchronous request for cola

I am so craving a Head First cola... Hey Rufus, will you go GET me a Head First cola from the store?

This is your request: you're asking your trusty dog Rufus to go GET you a cola.

Must get cola, must get cola...

You send your request...

3.1.2. An asynchronous request for cola

Now, compare that to this asynchronous request...

Hey Rufus, will you get me another cola?

Like before, you make a request to Rufus to go GET you a cola. Except this time, you tell him he's an asynchronous dog.

I'm gonna have to ask for a pay raise. More kibble.

Once again, your trusty dog Rufus goes off with your request to get your cola. This time, though, Rufus is an ASYNCHRONOUS dog....

Ow, my back!

...but because it's a synchronous request, you are totally and completely STUCK until the response comes back!

Finally, Rufus is on his way back with your cola...

Good boy, Rufus! But I gotta make you an asynchronous dog... my back can't take this anymore.

When you get the response, you get UN-stuck..

...which means you can do whatever you want while he's getting the cola. You're not stuck like you were when he was synchronous.

Rufus gets your cola back to you right as you're needing a break on the 17th green. Golf and refreshment: perfect!

The result is the same: you get your cola. The difference is that you weren't completely stuck while you were waiting for it.




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