Ver Mensaje Individual
  #11 (permalink)  
Antiguo 15/07/2012, 19:40
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: condicional resultado responseText no funciona

Cita:
Iniciado por Panino5001 Ver Mensaje
Ese es tu error de concepto: la redirección ocurre antes y la página no devuelve nada. Deberías quitar ese header.
Y luego hacer algo así:
Código PHP:
if(Ajax.responseText=='loginOK'){
    
window.location='páginaprotegida.php';//o location.reload();

}else{
   
alert('USUARIO O CLAVE INCORRECTOS');

@panino5001
Si bien insito en que @pithon no tiene elmétodo muy definido, eso no es tan asi

digamos que tengo una página index.html con
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript" src="cargaAjax.js"></script>
  7. </head>
  8. <a href="#" onclick="cargarAjax('redir.php','contenedorAjax');return false;">test</a><br />
  9. <div id="contenedorAjax">
  10. </div>
  11. </body>
  12. </html>

la función cargarAjax() son mis rutinas para crear el XMLHttpRequest

nuestro redir.php tiene

Código PHP:
Ver original
  1. <?php
  2. header("location:html4.html");
  3. ?>

y nuestro html4.html tiene por código
Código HTML:
Ver original
  1. Hola

El div de id "contenedorAjax" en index.html va a mostrar el texto
Hola

Es decir la redirección se hace, y existe Ajax.responseText.
Para que tanta vuelta con la redirección, no lo sé

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.