On this page
JavaScript: FormData
JavaScript: FormData
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”.
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.
Learn more at MDN Web Docs – FormData.
Get a form action/URL with jQuery:
$('#myForm').attr('action');
How to Create Image and File Upload in PHP with jQuery AJAX: The Basics of File Upload in PHP