Skip to Content
JavaScript: The Definitive Guide, 6th Edition
book

JavaScript: The Definitive Guide, 6th Edition

by David Flanagan
May 2011
Intermediate to advanced
1093 pages
40h 54m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, 6th Edition

Name

FormData — an HTTP multipart/form-data request body

Synopsis

The FormData type is a feature of XMLHttpRequest Level 2 (XHR2) that makes it easy to perform HTTP PUT requests with multipart/form-data encoding using an XMLHttpRequest. Multipart encoding is necessary, for example, if you want to upload multiple File objects in a single request.

Create a FormData object with the constructor, and then add name/value pairs to it with the append() method. Once you have added all of the parts of your request body, you can pass the FormData to the send() method of an XMLHttpRequest.

Constructor

new FormData()

This no-argument constructor returns an empty FormData object.

Methods

void append(string name, any value)

This method adds a new part, with the specified name and value, to the FormData. The value argument can be a string or a Blob (recall that File objects are Blobs).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: The Definitive Guide, 5th Edition

JavaScript: The Definitive Guide, 5th Edition

David Flanagan

Publisher Resources

ISBN: 9781449393854Errata PageSupplemental Content