
Problemas al agregar un archivo.js por etiqueta script
Publicado por matias (6 intervenciones) el 25/12/2016 07:20:59
Hola, que tal? bueno, estoy aprendiendo AJAX y Javascript, y lo que quiero desarrolar es un Registro de usuraio, que cundo vas escribiendo tu nombre de usuario, por medio ajax comprueba si el nombre esta disponible. Eso ya lo logre, pero queria sacar al funcion de javascript en un .JS externo y llamarlo por una etiqueta scrpt para que el codigo sea mas prolijo, pero no importa lo que haga, nunca llama al a funcion en el JS. este es el codigo.
Si pudieran revisar el código o darme un buen tutorial de como se llama la funcion de un archivo js externo desde un html, lo agradeciere mucho
Este es el codigo html, donde si pongo la funcion del JS directamente aca, funciona perfecto,
y Este es el codifo del vJS ver.js, que ya se que funciona, pero nunca es invocado por la funcion del HTML
Si pudieran revisar el código o darme un buen tutorial de como se llama la funcion de un archivo js externo desde un html, lo agradeciere mucho
Este es el codigo html, donde si pongo la funcion del JS directamente aca, funciona perfecto,
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
<!DOCTYPE html>
<html>
<head>
<title> Ttitulo</title>
<!-- ESTA ES LA ETIQEUTA DEL JS QUE ESTA EL CODIGO AL FINAL DEL TEMA>
<script type="text/javascript" src="./ver.js"></script>
</head>
<body>
<script type="text/javascript" src="./ver.js"></script>
<table>
<tr>
<td>
<form action="Registrarce.php" method="post">
<td> Registrarce </tr>
<tr> nombre : <input type="textarea" name="nombre" onkeyup="showHint(this.value)">
<p>Suggestions: <span id="txtHint"></span></p>
<tr> mail : <input type="textarea" >
<tr> contraseña : <input type="textarea" >
<input type="submit" name="Registrarce">
</form>
</td>
<td>
</td>
</tr>
</table>
</body>
</html>
y Este es el codifo del vJS ver.js, que ya se que funciona, pero nunca es invocado por la funcion del HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function showHint(str) {
var xhttp;
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("txtHint").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "IniciarSesionParaJS.php?q=" + str, true);
xmlhttp.send();
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
Valora esta pregunta


0