-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demo09-2.html
35 lines (30 loc) · 1002 Bytes
/
Demo09-2.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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo 09-2</title>
</head>
<body>
<button onclick="consultarServicio()">Traer informacion de Servicio</button>
<p id="mensaje"></p>
</body>
<script>
function consultarServicio() {
let request = new XMLHttpRequest();
request.open("GET", "data_ejemplo.json", true);
request.onloadstart = function () {
document.getElementById("mensaje").innerText = "Consultando al Servidor";
};
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
document.getElementById("mensaje").innerText = "";
console.table(JSON.parse(request.responseText));
}
}
request.send();
var usuario = 'Maria';
var edad = 43;
}
</script>
</html>