Skip to Main Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate content levelBeginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
133
duplication prohibited
The browser will always run your callback,
because that gives you a chance to respond to
whatever the server did to handle your request.
Since you’re using an asynchronous request, the
callback is the only way you have to write code that can
deal with a server’s response. To help you out with
dealing with that response, the browser gives you both the
state of your request, and the status of your request.
There’s a different between the state of your request, and
the status of the same request. Your request’s ready state
tells the browser what stage of processing the request is in:
initialization, processing, completed, etc.. But just because
a request is complete doesn’t mean that the request was
successful... that involves the status of the request.
A server reports any problems with a request by using a status
code. The status code indicates what happened during the request,
and whether things went as you intended. So even if a request
was completed, you still need to make sure the status code for the
request indicates that everything went OK.
OK, so I see how it’s getting to the server. But if
the server can’t nd the program in the request URL
to run, why does the browser still run our callback?
Shouldn’t it report an error or something?
The browser always runs your callback...
...and it did report an error.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Head First Ajax

Head First Ajax

Rebecca M. Riordan

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content