
26/06/2013, 14:35
|
 | | | Fecha de Ingreso: octubre-2011 Ubicación: mexico
Mensajes: 760
Antigüedad: 13 años, 4 meses Puntos: 8 | |
Respuesta: tengo un problema muy interesante sobre ajax Cita:
Iniciado por Franz1628 Lo que puedes hacer es traerlo como xml
Código PHP:
Ver original<?php header('Content-Type: text/xml'); echo "<?xml version=\"1.0\"?><var>".$_GET['var']."</var><c2>".$_GET['c2']."</c2>"; ?>
DEbes modificar tu funcion respuestaAjax algo asi
Código Javascript :
Ver originalfunction respuestaAjax(){ if(peticion.readyState==4) { if(peticion.status==200) { //alert(peticion.responseText); var dina = peticion.responseXML.getElementsByTagName("var")[0]; var apellidoDiv= peticion.responseXML.getElementsByTagName("c2")[0]; document.getElementById("dina").innerHTML=dina.childNodes[0].nodeValue; document.getElementById("apellidoDiv").innerHTML=apellidoDiv.childNodes[0].nodeValue; } else { alert("ha ocurrido un error"+peticion.statusText); } } else { document.getElementById("dina").innerHTML='<img src="carga.gif" />'; } }
Saludos entonces me recomiendas
que le meta xml
y con eso lo puedo hacer
es correcto |