Getting the progress of an asynchronous request
Our request is pretty lightweight but that's not always going to be the case in your application. Moreover, progressing is especially important in mobile web applications, where the mobile device may move in and out of network coverage and suffer temporary network outages. A robust application will test progress status and errors and retry important requests.
The XMLHttpRequest
object provides events for it to notify you about the progress of a pending request. These events are as follows:
load
: This event executes immediately after you open a connection.loadstart
: This event executes as a load first starts.progress
: This event executes periodically as the load takes place.error
: This event executes in the event of a network error.abort
: This event executes in the event that the network transaction is aborted (such as the user navigating away from the page issuing the request).
How to do it...
For each of these events, you'll want to...