Book Image

JavaScript JSON Cookbook

By : Ray Rischpater, Brian Ritchie, Ray Rischpater
Book Image

JavaScript JSON Cookbook

By: Ray Rischpater, Brian Ritchie, Ray Rischpater

Overview of this book

Table of Contents (17 chapters)
JavaScript JSON Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 register a...