FormData.getAll()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
备注: 此特性在 Web Worker 中可用。
getAll()
方法会返回该 FormData
对象指定 key 的所有值。
语法
js
formData.getAll(name);
参数
返回
一个 FormDataEntryValue
数组。
示例
下列代码会先创建一个空的 FormData
对象:
js
var formData = new FormData();
使用 FormData.append
添加两个 username 的值:
js
formData.append("username", "Chris");
formData.append("username", "Bob");
下列 getAll()
方法会返回一个数组,包含了所有 username
的值:
js
formData.getAll("username"); // Returns ["Chris", "Bob"]
规范
Specification |
---|
XMLHttpRequest # dom-formdata-getall |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getAll |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.