JavaScript Objects: FormData

By: Dusty Arlia
Published on Wednesday, January 1, 2014, 03:09 PM
Last Updated on Thursday, July 09, 2015 at 11:09 PM
Total Updates: 2

The FormData JavaScript object is an HTTP multipart/form-data request body. This is a feature of XMLHttpRequest Level 2 (XHR2). FormData makes it easy to perform HTTP PUT requests with multipart/form-data encoding using an XMLHttpRequest. This is useful if you want to upload multiple File objects in a single request. Create a FormData object using the FormData() constructor like this:

new FormData()

Then add name/value pairs to it with the append() method like so:

append([name],[value])

You can then pass the FormData object to the send() method of an XMLHttpRequest.

Comments:

Ad: