Estoy tratando de traer datos con una consulta MySql y un while que están en otra página, mediante:
Código Javascript:
Ver original
function traer() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { newdiv.innerHTML = xmlhttp.responseText; } var newdiv = document.createElement("div"); var container = document.getElementById("mydiv"); container.appendChild(newdiv); xmlhttp.open("GET","pageconsulta.php",true); xmlhttp.send(); }
pero no me los trae. Si el dato viene de :
(pageconsulta.php:)
Código MySQL:
Ver original
.... .... while($reg=mysql_fetch_array($registros)) { $valor=$reg['valor']; print<<<HERE $valor<br /> HERE; }
no me trae nada. Si solo intento traer un dato con if(...) en lugar de while(..) no hay problema.
A lo mejor es que no se pueden traer datos de un while porque no se pueden tratar como un objeto en Ajax, o algo así (?).
No sé si habría alguna manera de solucionar ésto.
Agradecería cuaulquier ayuda..
Saludos