AJAX - The Complete Reference

(avery) #1

142 Part I: Core Ideas


beyond the x-www-form-urlencoded format, but you are free to do so if you like. As a final
example, you may experiment with all the formats we presented in this chapter in one single
example at http://ajaxref.com/ch4/requestexplorer.html, which is shown in Figure 4-4.

File Attachments


Before we finish the request half of our discussion, there is one special type of format that
requires a brief discussion: file attachments. As discussed in Chapter 2, when uploading
files you are very limited in the communication techniques allowed. It will be necessary to
use an <iframe> and target the form that contains the file upload control(s) to this form.
You should read the examples in Chapter 2 for the details of the technique, as our focus here
is on the data format. If you inspect a multiple file upload example more closely, you will
see that it has a number of interesting characteristics. First, the Content-Type header will
be set to multipart/form-data. It will also indicate a boundary indicator of some sort like
-----808ab990c or something similar. This will be used as a marker to indicate the start
and end of a particular attachment. Each attachment will also have a Content-
Disposition header value set that indicates the filename and location as well as Content-
Type header indicating the MIME type of the particular attachment. You can see all these
components here:

FIGURE 4-4 Exploring request data formats
Free download pdf