-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajex-text.html
32 lines (27 loc) · 922 Bytes
/
ajex-text.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX</title>
</head>
<body>
<p id="demo">Here we load data.</p>
<button onclick="loadData()">Click</button>
<script>
function loadData() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.response;
} else if (this.readyState == 4 && this.status == 404) {
document.getElementById("demo").innerHTML = "file not found";
}
};
xhttp.open('GET', "readme.txt", true);
xhttp.send();
}
</script>
</body>
</html>