Este es mi página:
Código HTML:
<head > <script type="text/javascript" src="funciones.js"></script> </head> <body> <table width="300px" cellpadding="0" cellspacing="0"> <tr style="height:25px"> <td height="25" colspan="2" align="center" class="titleDiv" >Iniciar Sesión</td> </tr> <tr style="height:25px"> <td height="26" align="right">Nombre de Usuario:</td> <td><input type="text" name="username" id="user" /></td> </tr style="height:25px"> <tr> <td height="28" align="right">Contraseña:</td> <td><input type="password" name="password" id="pass" /></td> </tr > <tr style="height:25px"> <td></td> <td><input type="button" name="btnIniciar" id="ingresar" value="Iniciar Sesión" onclick="validar()" /></td> </tr> </table> </body>
Código:
hasta aqui todo esta validado... el problema es cuando hago la funcion verDB():function validar()
{
var user = document.getElementById('user');
var pass = document.getElementById('pass');
if((user.value == "") && (pass.value == ""))
{
alert("Debes ingresar Datos");
user.focus();
}
else
{
if(user.value == "")
{
alert("debes escribir tu nombre de usuario");
user.focus();
}
else
{
if(pass.value == "")
{
alert("debes escribir una contraseña");
pass.focus();
}
else
{
//compararlos a la base de datos:
verDB();
}
}
}
}
Código:
Cuando pongo esto ya no me hace nada...function objetoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function verDB()
{
var ajax=objetoAjax();
var user = document.getElementById('user');
var pass = document.getElementById('pass');
ajax.open("POST", "loginCheck.php", false);
ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
var respuesta = ajax.responseText
if(respuesta == "pass")
{
alert("La contraseña no es correcta");
pass.value = "";
pass.focus();
}
if(respuesta == "user")
{
alert("el nombre de usuario no existe");
user.value = "";
user.focus();
}
if(respuesta == "logged")
{
location.href="home.php";
}
}
}
ajax.send("user="+user.value"&pass="+pass.value)
}
Ayuda


