mozilla
Your Search Results

    FormData

    XMLHttpRequest Level 2 adds support for the new FormData interface. FormData objects provide 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".

    Note: For details on how to use the FormData object, see Using FormData objects.

    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.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/value pair.
    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.

    Note: To be clear, the difference between FormData.set() and FormData.append() is that if the specified key does already exist, FormData.set() will overwrite the existing value with the new one, whereas FormData.append() will append the new value onto the end of the existing values. See their dedicated pages for example code.

    Specifications

    Specification Status Comment
    XMLHttpRequest
    The definition of 'FormData' in that specification.
    Living Standard FormData defined in XHR spec

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 7+ 4.0 (2.0) 10+ 12+ 5+
    append with filename (Yes) 22.0 (22.0) ? ? ?
    delete, get, getAll, has, set Behind Flag Not supported Not supported (Yes) Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support 3.0 ? 4.0 (2.0) 1.0.1 ?

    12+

    ?
    append with filename ? ? 22.0 (22.0) 1.2 ? ? ?
    delete, get, getAll, has, set (Yes) (Yes) Not supported Not supported Not supported (Yes) Not supported

    Note: XHR in Android 4.0 sends empty content for FormData with blob.

    Note: Chrome support for methods other than append is currently behind the "Enable Experimental Web Platform Features" flag.

    Gecko notes

    Prior to Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4), if you specified a Blob as the data to append to the object, the filename reported in the "Content-Disposition" HTTP header was an empty string; this resulted in errors being reported by some servers. Starting in Gecko 7.0, the filename "blob" is sent.

    See also