-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax11.html
97 lines (72 loc) · 2.34 KB
/
ajax11.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ajax Tutorial 11</title>
<style type="text/css">
table{
width: 30%;
border-collapse: collapse;
-webkit-box-shadow: 7px 7px 23px -4px rgba(0,0,0,0.75);
-moz-box-shadow: 7px 7px 23px -4px rgba(0,0,0,0.75);
box-shadow: 7px 7px 23px -4px rgba(0,0,0,0.75);
}
table, td, th {
border: 1px solid #cccccc;
padding: 5px;
}
th{
text-align: left;
}
tr:nth-child(even){
background-color: #E8ECED;
}
</style>
</head>
<body>
<center>
<h1>Tutorial 11 AJAX</h1>
<h3>PHP - Mysql Seleccionar Usuario</h3>
<h3>Seleccione el Usuario</h3>
<select onchange="mostrarusuario(this.value)">
<option value="">Seleccionar Persona</option>
<option value="1">Yoimar </option>
<option value="2">Pia </option>
<option value="3">Ramon </option>
<option value="4">Yelina </option>
</select>
<h3>Información</h3>
<div id="info"></div>
</center>
<script type="text/javascript">
/* Variable para llamar al document getElementById con info tener el div en una variable */
var resultado = document.getElementById('info');
function mostrarusuario(usuario){
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
if (usuario === ""){
resultado.innerHTML = "";
} else {
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState === 4 && xmlhttp.status === 200){
//La respuesta que obtenga (xmlhttp.responseText) la muestro en resultado
resultado.innerHTML = xmlhttp.responseText;
}
};
//Abro el archivo del servidor donde envio los parametros
xmlhttp.open("GET", "servidor11.php?usuario="+usuario, true);
// Envio la respuesta
xmlhttp.send();
//Fin del else
}
//Fin de la funcion mostrar usuario
}
</script>
</body>
</html>