Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/03/2006, 01:54
Avatar de txus35
txus35
 
Fecha de Ingreso: mayo-2005
Mensajes: 42
Antigüedad: 19 años
Puntos: 0
GET(url,true) no funciona

Hola,
Quiero cambiar de página mediante AJAX pero no sucede nada. El código lo dejo aquí abajo, es muy sencillo y le he dado mil vueltas sin éxito. El script muestra la alerta "statusText_1" y ajax.statusText vale "OK" pero la página "hola.htm" no se muestra.
Seguro que ustedes le sacan el error. Un saludo.

Código HTML:
<html>
<head>
<script>
function showPage(){
	var ajax=false;
	ajax = new ActiveXObject("Msxml2.XMLHTTP"); //abreviando, tomo método para mi navegador (IE)
	var url="http://www.midominio.com/hola.htm"; //sencilla página estática HTML
	ajax.open("GET", url,true);
	ajax.onreadystatechange=function() {
	 	if (ajax.readyState==1) alert("statusText_0: "+ajax.statusText);	
		if (ajax.readyState==4) {	
			if (ajax.status==200 || ajax.status==304) alert("statusText_1: "+ajax.statusText+"\n"+url);
			else alert("statusText_2: "+ajax.statusText);
			
			delete ajax;
		}//fin if
	 }//fin function onreadystatechange()
	 ajax.send(null);
}//fin function showPage
</script>
</head>
<body>
<a href="javascript:showPage();" target="_self">ver página</a>
</body>
</html> 

Última edición por txus35; 08/03/2006 a las 02:09