-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
37 lines (31 loc) · 981 Bytes
/
test.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
33
34
35
36
37
<!DOCTYPE html>
<html>
<body>
<button id="ajaxButton" type="button">Make a request</button>
<script>
(function() {
var httpRequest;
document.getElementById("ajaxButton").addEventListener('click', makeRequest);
function makeRequest() {
httpRequest = new XMLHttpRequest();
if (!httpRequest) {
console.error('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
httpRequest.onreadystatechange = logContents;
- httpRequest.open('GET', 'http://brme.fr/index.php/api/rooms');
httpRequest.send();
}
function logContents() {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
console.log('success', httpRequest.responseText);
} else {
console.error('There was a problem with the request.', httpRequest);
}
}
}
})();
</script>
</body>
</html>