AJAX - The Complete Reference

(avery) #1

Chapter 2: Pre-Ajax JavaScript Communications Techniques 59


PART I


Summary


There are numerous ways to transmit data to a Web server without using the
XMLHttpRequest (XHR) object commonly associated with Ajax. Some of these methods,
such as the image request technique, are simple and easy to use, particularly in one-way
communication patterns. However, the techniques do have their limitations. Most of the
traditional methods are limited to data passing within the query string or a cookie which
are themselves limited in the amount of data that can be sent. Inline frames, however, can
get around such data size limitations with hidden form posting, but may pay for the power
with added cross-browser complexity as well as some potential user interface quirks.
Iframes are also valuable in that they can be used to perform file uploads. While all of these
pre-Ajax techniques can be made to work as we showed in numerous examples, they often
have less then adequate support for callbacks and error handling, forcing developers to
come up with workarounds. The XHR object discussed in the next chapter will address
many of these network- and content-related problems. However, do not forget about these
methods since the general pattern followed will be the same for the XHR examples.
Furthermore, the limitations of the XHR object with regard to file uploading, cross domain
scripting limitations, and history problems will force us to return to these tried and true
JavaScript-based communication techniques.

FIGURE 2-12 Reading an RSS feed from JavaScript
Free download pdf