The FormData
interface provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send()
method. It uses the same format a form would use if the encoding type were set to "multipart/form-data"
.
You can also pass it directly to the URLSearchParams
constructor if you want to generate query parameters in the way a <form>
would do if it were using simple GET
submission.
An object implementing FormData
can directly be used in a for...of
structure, instead of entries()
: for (var p of myFormData)
is equivalent to for (var p of myFormData.entries())
.
Note: This feature is available in Web Workers.
Constructor
FormData()
- Creates a new
FormData
object.
Methods
FormData.append()
- Appends a new value onto an existing key inside a
FormData
object, or adds the key if it does not already exist. FormData.delete()
- Deletes a key/value pair from a
FormData
object. FormData.entries()
- Returns an
iterator
allowing to go through all key/value pairs contained in this object. FormData.get()
- Returns the first value associated with a given key from within a
FormData
object. FormData.getAll()
- Returns an array of all the values associated with a given key from within a
FormData
. FormData.has()
- Returns a boolean stating whether a
FormData
object contains a certain key. FormData.keys()
- Returns an
iterator
allowing to go through all keys of the key/value pairs contained in this object. FormData.set()
- Sets a new value for an existing key inside a
FormData
object, or adds the key/value if it does not already exist. FormData.values()
- Returns an
iterator
allowing to go through all values contained in this object.
Specifications
Specification | Status | Comment |
XMLHttpRequestThe definition of 'FormData' in that specification. | Living Standard | FormData defined in XHR spec |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
FormData
|
Chrome
Full support 7 |
Edge
Full support 12 |
Firefox Full support 4 Full support 4 Notes' Prior to Firefox 7, specifying a |
IE
Full support 10 |
Opera
Full support 12 |
Safari
Full support 5 |
WebView Android Full support ≤37 Full support ≤37 Notes' XHR in Android 4.0 sends empty content for |
Chrome Android
Full support 18 |
Firefox Android Full support 4 Full support 4 Notes' Prior to Firefox 7, specifying a |
Opera Android
Full support 12 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
FormData() constructor
|
Chrome
Full support 7 |
Edge
Full support 12 |
Firefox
Full support 4 |
IE
Full support 10 |
Opera
Full support 12 |
Safari
Full support 5 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 12 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
Support of for...of
|
Chrome
Full support 50 |
Edge
Full support 79 |
Firefox
Full support 44 |
IE
? |
Opera
? |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 44 |
Opera Android
? |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
append
|
Chrome
Full support 7 |
Edge
Full support 12 |
Firefox Full support 4 Full support 4 Notes' Prior to Firefox 7, specifying a |
IE Full support 10 Full support 10 Notes' With the "Include local directory pass when uploading files to a server" option enabled, IE will change the filename inside the |
Opera
Full support 12 |
Safari
Full support 5 |
WebView Android Full support 3 Full support 3 Notes' XHR in Android 4.0 sends empty content for |
Chrome Android
Full support 18 |
Firefox Android Full support 4 Full support 4 Notes' Prior to Firefox 7, specifying a |
Opera Android
Full support 12 |
Safari iOS
Full support 5 |
Samsung Internet Android
Full support 1.0 |
delete
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 39 |
IE
No support No |
Opera
Full support Yes |
Safari
Full support 11 |
WebView Android
Full support Yes |
Chrome Android
Full support 50 |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
entries
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 44 |
IE
No support No |
Opera
Full support 37 |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 44 |
Opera Android
Full support 37 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
get
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 39 |
IE
No support No |
Opera
Full support 37 |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 39 |
Opera Android
Full support 37 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
getAll
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 39 |
IE
No support No |
Opera
Full support 37 |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 39 |
Opera Android
Full support 37 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
has
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 39 |
IE
No support No |
Opera
Full support Yes |
Safari
Full support 11 |
WebView Android
Full support Yes |
Chrome Android
Full support 50 |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
keys
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 44 |
IE
No support No |
Opera
Full support Yes |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 44 |
Opera Android
? |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
set
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 39 |
IE
No support No |
Opera
Full support 37 |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 39 |
Opera Android
Full support 37 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
values
|
Chrome
Full support 50 |
Edge
Full support 18 |
Firefox
Full support 44 |
IE
No support No |
Opera
Full support 37 |
Safari
Full support 11 |
WebView Android
Full support 50 |
Chrome Android
Full support 50 |
Firefox Android
Full support 44 |
Opera Android
Full support 37 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 5.0 |
Available in workers | Chrome
Full support Yes |
Edge
Full support ≤18 |
Firefox
Full support 39 |
IE
No support No |
Opera
Full support Yes |
Safari
No support No |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
No support No |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.'
- See implementation notes.
See also
FormData by Mozilla Contributors is licensed under CC-BY-SA 2.5.