回答編集履歴
1
chousei
test
CHANGED
@@ -2,19 +2,15 @@
|
|
2
2
|
|
3
3
|
```javascript
|
4
4
|
|
5
|
-
|
5
|
+
const a=["a","b","c"];
|
6
|
-
|
7
|
-
var formdata = new FormData();
|
8
|
-
|
9
|
-
for(i=0;i<a.length;i++){
|
10
|
-
|
11
|
-
formdata.append("a[]",a[i]);
|
12
|
-
|
13
|
-
}
|
14
6
|
|
15
7
|
const url="sample.php";
|
16
8
|
|
9
|
+
const method="post";
|
10
|
+
|
11
|
+
const body=a.reduce((x,y)=>(x.append("a[]",y),x),new FormData());
|
12
|
+
|
17
|
-
fetch(url,{method
|
13
|
+
fetch(url,{method,body}).then(res=>res.text()).then(console.log);
|
18
14
|
|
19
15
|
```
|
20
16
|
|