回答編集履歴
1
ちょうせい
answer
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
普通にfetchで受ければ普通に表示されます
|
2
2
|
```javacript
|
3
3
|
fetch('sample.json').then(res=>res.json()).then(console.log);
|
4
|
+
```
|
5
|
+
|
6
|
+
```javascript
|
7
|
+
<script>
|
8
|
+
window.addEventListener('DOMContentLoaded', ()=>{
|
9
|
+
btn.addEventListener('click',async()=>{
|
10
|
+
const params={txt:document.querySelector('#lend').value};
|
11
|
+
const url='views.py?'+Object.entries(params).map(x=>x.map(encodeURIComponent).join('=')).join('&');
|
12
|
+
const data=await fetch(url).then(res=>res.json());
|
13
|
+
text.textContent=JSON.stringify(data);
|
14
|
+
});
|
15
|
+
});
|
16
|
+
</script>
|
17
|
+
<input id="lend" value="てすと">
|
18
|
+
<span>文字を入力した後にボタンを押してください</span>
|
19
|
+
<button type="button" id="btn">貸出</button>
|
20
|
+
<span id="text"></span>
|
21
|
+
<span id="text2"></span>
|
22
|
+
|
4
23
|
```
|