> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/form/.formdata.md).

# .formData()

Creates and returns a new FormData() object for the selected form.

## `$('#form').formData()`

#### **Example**

```html
<form id="myForm">
  <input name="username" value="Smith">
  <input name="email" value="user@example.com">
</form>
```

```javascript
const fd = $('#myForm').formData();
console.log(fd.get('username')); // Smith
```

#### Notes

* Throw error if selector is not a `<form>`.
* Works perfectly for AJAX uploads and `fetch()`.
