AJAX - The Complete Reference

(avery) #1

344 Part II: Developing an Ajax Library^


being received, the data being consumed, a retry occurring, or an error happening. A few
ideas of such changes are shown here:

An example to explore such indications can be found at http://ajaxref.com/ch8/
detailedprogress.html. As you inspect it, note the changes introduced to the AjaxTCR
library progress features discussed in Chapter 5. In order to allow for more granular
progress information, the statusIndicator object found in the options object has been
extended, as shown in Table 8-1.
In the case of very long network transactions, such as a large file upload or some long
running query, it is likely a good idea to provide some ongoing status. In Chapter 2, we
presented a basic file upload example using iframes, as XHRs generally cannot be used for
file uploading. While some of the examples include a progress bar like the previous
animated GIF based progress indicators, they did not provide any real indication of upload
progress. However, with a bit more work, it is possible to make a real progress bar by
simultaneously issuing extra requests to monitor the status of the upload and update the
progress bar, or by setting an appropriate message about the upload status. As an example,
the following is a form that would be used to upload a file.

<form enctype="multipart/form-data" name="requestForm" method="POST"
target="uploadresult">

Extended Status Indicator Properties Description
statusIndicator.progress.text Set to a string to display during all
unspecified aspects of a request.
statusIndicator.progress.imgSrc Set to a URL of the image to show in
all unspecified aspects of a request.
statusIndicator.progress.sending.text
statusIndicator.progress.sending.imgSrc

Text or images can be set to display
for the sending portion of a request.
statusIndicator.progress.receiving.text
statusIndicator.progress.receiving.imgSrc

Text or images can be set to display
for the receiving portion of a request.
statusIndicator.error.text
statusIndicator.error.imgSrc

Text or images can be set to display
when an error occurs.
statusIndicator.retry.text
statusIndicator.retry.imgSrc

Text or images can be set to display
when a retry occurs.

TABLE 8-1 Extensions to AjaxTCR statusIndicator Object
Free download pdf