Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/10/2006, 07:30
Avatar de ikhuerta
ikhuerta
 
Fecha de Ingreso: octubre-2006
Mensajes: 104
Antigüedad: 17 años, 7 meses
Puntos: 0
Yo suelo partir el trabajo de ajax en 2 funciones.

La primera se encarga del antes y llama a la segunda en el onreadystatechange --> readyState == 4

es decir. hacemos algo asi:

Código:
function PRIMERA()
{
xhr=crear_objeto_XHR()
xhr(open.... .... ... );
xhr.onreadystatechange=function(){if (XHR[n].readyState==4){	
if (XHR[n].status==200){ SEGUNDA(XHR.responseText;) }}}
// ZONA PARA MARCAR QUE HA EMPEZADO AJAX
document.getElementById("tu_id").innerHTML="QUE ESTOY CARGANDO COÑO!";
// Y LANZAMOS
xhr.send();
}

function SEGUNDA(texto_respuesta)
{
document.getElementById("tu_id_segunda").innerHTML=texto_respuesta;


}

NOTA: todo este codigo está mal escrito, es solo pa que veas la idea.