回答編集履歴

4

調整

2022/11/02 01:35

投稿

yambejp
yambejp

スコア115433

test CHANGED
@@ -7,12 +7,11 @@
7
7
  const signal = controller.signal;
8
8
  dlg.showModal();
9
9
  const res=await fetch('sample.php',{signal}).then(res=>res.text()).then(txt=>{
10
- dlg.close();
11
10
  alert(txt);
12
11
  }).catch(err=>{
13
- dlg.close();
14
12
  alert(err);
15
13
  });
14
+ dlg.close();
16
15
  });
17
16
  dlg.querySelector('.cancel').addEventListener('click',()=>{
18
17
  controller.abort();

3

調整

2022/11/02 01:33

投稿

yambejp
yambejp

スコア115433

test CHANGED
@@ -16,7 +16,6 @@
16
16
  });
17
17
  dlg.querySelector('.cancel').addEventListener('click',()=>{
18
18
  controller.abort();
19
- dlg.close();
20
19
  });
21
20
  });
22
21
  </script>

2

typo

2022/11/01 12:55

投稿

yambejp
yambejp

スコア115433

test CHANGED
@@ -6,7 +6,7 @@
6
6
  controller = new AbortController();
7
7
  const signal = controller.signal;
8
8
  dlg.showModal();
9
- const res=await fetch('y.php',{signal}).then(res=>res.text()).then(txt=>{
9
+ const res=await fetch('sample.php',{signal}).then(res=>res.text()).then(txt=>{
10
10
  dlg.close();
11
11
  alert(txt);
12
12
  }).catch(err=>{

1

調整

2022/11/01 12:53

投稿

yambejp
yambejp

スコア115433

test CHANGED
@@ -1,11 +1,12 @@
1
1
  ```javascript
2
2
  <script>
3
3
  window.addEventListener('DOMContentLoaded', ()=>{
4
- const controller = new AbortController();
5
- const signal = controller.signal;
4
+ let controller;
6
5
  btn.addEventListener('click',async()=>{
6
+ controller = new AbortController();
7
+ const signal = controller.signal;
7
8
  dlg.showModal();
8
- const res=await fetch('sample.php',{signal}).then(res=>res.text()).then(txt=>{
9
+ const res=await fetch('y.php',{signal}).then(res=>res.text()).then(txt=>{
9
10
  dlg.close();
10
11
  alert(txt);
11
12
  }).catch(err=>{