The FormData
interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the fetch()
, XMLHttpRequest.send()
or navigator.sendBeacon()
methods. 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 (const p of myFormData)
is equivalent to for (const p of myFormData.entries())
.
Note: This feature is available in Web Workers.