Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Problema con ajax

Estas en el tema de Problema con ajax en el foro de Frameworks JS en Foros del Web. Código: function toggle(what) { var aobj = document.getElementById(what); if( aobj.style.display == 'none' ) { aobj.style.display = ''; } else { aobj.style.display = 'none'; } } ...
  #1 (permalink)  
Antiguo 23/02/2009, 12:58
Avatar de farra  
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Pregunta Problema con ajax

Código:
function toggle(what) {
        var aobj = document.getElementById(what);
        if( aobj.style.display == 'none' ) {
               aobj.style.display = '';
        } else {
               aobj.style.display = 'none';
        }
}
function CrearXMLHttp(){
	XMLHTTP=false;
	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	}else if(window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}
// suponiendo que tu div se llama loading
function OpenPage(url,id,loading){
//alert(url+' '+id);
	req=CrearXMLHttp();
	if(req){
		req.onreadystatechange = function() { manejador(id,loading); }; // aca cambie
		req.open("POST",url,true);
		req.send(null);
                toggle(loading); // ojo aqui
	}
}
function manejador(id,loading){
	if(req.readyState == 4){
		if(req.status == 200){
                        toggle(loading); // ojo aca
			document.getElementById(id).innerHTML=req.responseText;
		}else{
			alert("Error"+req.statusText)
		}
	}
}
llamada:
Código:
OpenPage('pagina.php','contenedor','cargando');


tengo un problema con esta funcion de ajax....

cuando abro en explorer, opera, safari, y chrome funciona perfecto, pero al utilizar con mozilla firefox no me funciona...

me tira un alert que dice "Errorlenght required"

a que puede deberse esto?
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)
  #2 (permalink)  
Antiguo 26/02/2009, 23:50
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Problema con ajax

Estás enviando con post, entonces tenés que agregar esta segunda línea:
Código PHP:
req.open("POST",url,true);
req.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:07.