回答編集履歴
1
ついき
test
CHANGED
@@ -16,24 +16,48 @@
|
|
16
16
|
|
17
17
|
?>
|
18
18
|
|
19
|
-
<button class="ok">ボタン</button>
|
20
|
-
|
21
19
|
<script>
|
22
20
|
|
23
|
-
do
|
21
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
24
22
|
|
25
|
-
c
|
23
|
+
document.querySelector('.ok').addEventListener('click',()=>{
|
26
24
|
|
27
|
-
const
|
25
|
+
const url="test.php";
|
28
26
|
|
29
|
-
body
|
27
|
+
const body=new FormData();
|
30
28
|
|
31
|
-
|
29
|
+
body.append('get_data','myData');
|
32
30
|
|
31
|
+
const method="post";
|
32
|
+
|
33
|
-
fetch(url,{body,method}).then(res=>res.text()).then(console.log);
|
33
|
+
fetch(url,{body,method}).then(res=>res.text()).then(console.log);
|
34
|
+
|
35
|
+
});
|
34
36
|
|
35
37
|
});
|
36
38
|
|
37
39
|
</script>
|
38
40
|
|
41
|
+
<form method="get">
|
42
|
+
|
43
|
+
<input type="hidden" name="get_data" value="myData">
|
44
|
+
|
45
|
+
<input type="submit" value="get">
|
46
|
+
|
47
|
+
</form>
|
48
|
+
|
49
|
+
<form method="post">
|
50
|
+
|
51
|
+
<input type="hidden" name="get_data" value="myData">
|
52
|
+
|
53
|
+
<input type="submit" value="post">
|
54
|
+
|
55
|
+
</form>
|
56
|
+
|
57
|
+
<button class="ok">ボタン</button>
|
58
|
+
|
59
|
+
|
60
|
+
|
39
61
|
```
|
62
|
+
|
63
|
+
※get/postの動作を確認できるように追記しました
|