AJAX - No se como hacerle...

 
Vista:

No se como hacerle...

Publicado por Pepe (15 intervenciones) el 16/08/2007 19:32:29
HOLA TENGO ESTE CODIGO EN UN ARCHIVO

...
var url="getusr.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var respuesta = xmlHttp.responseText;
if (respuesta.length > 0)
{
var temp = new Array();
temp = respuesta.split('|');
document.getElementById("txtHint1").innerHTML= temp[0];
document.getElementById("txtHint2").innerHTML= temp[1];
document.getElementById("txtHint3").innerHTML= temp[2];
}
}
}

Y TENGO ESTE EN OTRO

...
var url="getusr.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}

COMO LE PUEDO HACER PARA TENERLOS EN EL MISMO ARCHIVO , NO SE COMO PONER LA URL Y EL xmlHttp.onreadystatechange=stateChanged PARA QUE ENTRE A UNA FUNCIO O A OTRA....

ESPERO ME HAYA EXPLICADO DE ANTEMANO GRACIAS...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 30
Ha mantenido su posición en AJAX (en relación al último mes)
Gráfica de AJAX

RE:No se como hacerle...

Publicado por Yamil Bracho (184 intervenciones) el 22/08/2007 18:59:42
Retorna las respuestas separadas por algun caracter y luego haces algo como

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var arr = xmlHttp.responseText.split('|');
document.getElementById("txtHint1").innerHTML = arr[0];
document.getElementById("txtHint2").innerHTML = arr[1];
document.getElementById("txtHint3").innerHTML = arr[2];

}
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar