HTML and CSS Reference
In-Depth Information
Table 11-3. Events of the XMLHttpRequest Object
Raised whenever the readyState value changes for an asynchronous request. You
can use this event to track the request from the time it's made to its completion.
Indicates that the request operation has begun.
Raised when the request has completely downloaded. The load event can be an
alternative to using the readystatechange event to track request completion.
Indicates that the request operation has stopped.
Raised multiple times while the data is being downloaded or uploaded.
Raised when a request is timed out.
Raised when a request is cancelled.
Raised whenever there is an error while making the request.
If you used XMLHttpRequest prior to HTML5, recollect that developers mostly relied on the
readystatechange event for any sort of tracking including request completion and error handling.
However, XMLHttpRequest Level 2 provides task-specific events that you can use to make your code cleaner
and neater.
Note that the progress event is fired for the XMLHttpRequest object itself and also for the upload object
of the XMLHttpRequest instance. The former event tracks the progress of data being downloaded, whereas
the latter tracks the progress of the data being uploaded. By handling the progress event, you can display
the progress of the operation to the user, say in a progress bar.
Making Requests Using XMLHttpRequest
Now that you know the properties, methods, and events of the XMLHttpRequest object, let's develop an
application that illustrates how they're used. In this section, you develop an ASP.NET Web Forms-based
application as shown in Figure 11-3.
Figure 11-3. Customer List application developed using XMLHttpRequest
Search WWH ::

Custom Search