AJAX - The Complete Reference

(avery) #1

Chapter 3: XMLHttpRequest Object 99


PART I


{
// handle response
}
}
}
}

To see this idea in action, visit the example at http://ajaxref.com/ch3/abort.html. We
will cover techniques for handling timeouts and other network problems in much more
depth in Chapter 6.

NNOT EOTE It is not really correct to manually force a connection to go away by nulling out various
aspects of the request object or callback function or overwriting an existing XHR with another
request. It may have a similar feeling to the end user in some cases because a callback won’t
happen, but any changes may still happen on the server as the request, once sent, still happened.

Authentication with XHRs


In the course of building applications, you often want to restrict access to certain resources,
such as particular directories or files. A simple form of authentication called HTTP Basic
Authentication may be implemented on the Web server resulting in a browser challenging
a user like so:
Free download pdf