-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path3-xhr.html
More file actions
22 lines (19 loc) · 419 Bytes
/
Copy path3-xhr.html
File metadata and controls
22 lines (19 loc) · 419 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<html>
<body>
<div id="message"></div>
<script>
const message = document.getElementById('message');
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
message.innerHTML = (xhr.status === 200 ?
xhr.responseText : 'Error code: ' + xhr.status
);
}
};
xhr.open('GET', '/person', true);
xhr.send();
</script>
</body>
</html>