-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAPIjquery.html
More file actions
33 lines (33 loc) · 896 Bytes
/
APIjquery.html
File metadata and controls
33 lines (33 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetch API</title>
</head>
<body>
<button onclick="fetchdata()">Fetch Data</button>
<div id="mydiv"></div>
<script src="jquery-3.6.0.js"></script>
<script>
function fetchdata(){
mydiv=document.querySelector("#mydiv");
fetch('rasengan.txt')
.then(function(response)
{
alert("fetching data...");
return response.text();
})
.then(function(text)
{
alert("be ready!");
alert("here it comes!");
mydiv.innerHTML=text;
})
.catch(function(error){
console.log(error.message);
})
}
</script>
</body>
</html>