-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax17.html
179 lines (134 loc) · 4.34 KB
/
ajax17.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!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 17</title>
<style type="text/css">
.clase{
color:#0000FF;
}
button{
padding: 15px;
/* margin-top: 42%; */
font-size: 14px;
cursor: pointer;
}
div#overlay{
display: none;
z-index: 2;
background: #000000;
position: fixed;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
text-align: center;
}
div#informaciondelusuario{
display: none;
position: relative;
z-index: 3;
margin: 20px auto 0px auto;
width: 400px;
height: 250px;
background: #ffffff;
color: #000000;
border: 4px solid #cccccc;
font-size: 18px;
}
/* div#wrapper{
position: absolute;
top: 40px;
} */
#info{
padding: 20px;
}
#titulo{
width: 100%;
height: 12%;
background: #e9e9e9;
padding: -20px;
text-align: center;
font-family: arial;
font-size: 18px;
padding-top: 15px;
}
</style>
</head>
<body onload="mostrar_clientes()">
<center>
<h1>Tutorial 17 AJAX</h1>
<h3>Proyecto 1 | Mostrar Web page Overlay (Vacia)</h3>
<h3>Personas Registrados</h3>
<form>
Nombre: <input type="text" id="nombre" placeholder="Ingrese un Nombre de Usuario" onkeyup="buscar_usuario(this.value)"> <br /> <br />
</form>
<div id="wrapper">
<div id="mostrar"></div>
</div>
<div id="overlay"></div>
<div id="informaciondelusuario">
<div id="titulo">Información Personal</div>
<p id="info"></p>
<button onclick="toggleOverlay(this)">Cerrar</button>
</div>
</center>
<script type="text/javascript">
/* Variable para llamar al document getElementById con info tener el div en una variable */
var resultado = document.getElementById('mostrar');
function mostrar_clientes(){
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
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", "servidor17.php", true);
// Envio la respuesta
xmlhttp.send();
//Fin de la funcion mostrar usuario
}
function buscar_usuario(nombre){
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
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", "servidor17.php?nombre=" + nombre, true);
// Envio la respuesta
xmlhttp.send();
//Fin de la funcion mostrar usuario
}
function toggleOverlay(elemento) {
var overlay = document.getElementById("overlay");
var informaciondelusuario = document.getElementById("informaciondelusuario");
var info = document.getElementById("info");
overlay.style.opacity = .6;
if (overlay.style.display == "block") {
overlay.style.display = "none";
informaciondelusuario.style.display = "none";
}else{
overlay.style.display = "block";
informaciondelusuario.style.display = "block";
}
}
</script>
</body>
</html>