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

Error al recibir datos en ajax

Estas en el tema de Error al recibir datos en ajax en el foro de Frameworks JS en Foros del Web. Hola que tal amigos vengo con esta otra duda estoy tratando de recibir un dato por medio de un XML según yo todo esta bien ...
  #1 (permalink)  
Antiguo 26/09/2011, 14:40
 
Fecha de Ingreso: noviembre-2010
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 5
Exclamación Error al recibir datos en ajax

Hola que tal amigos vengo con esta otra duda estoy tratando de recibir un dato por medio de un XML según yo todo esta bien pero me regresa un valor* ‘undefined’
que es lo que pasa les incluyo el codigo AJAX
*
function createAjax()
{*
*** var xmlhttp=false;*
*** try*
*** {*
******* xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");*
*** }
*** catch(e)
*** {*
******* try
******* {*
*********** xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");*
******* }*
******* catch(E) { xmlhttp=false; }
*** }
** *if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }*
*** return xmlhttp;*
}
*
function login_ajax()
{
********* var this_objectUser = document.getElementById("txtUser");
********* var this_objectPass = document.getElementById("txtPassword");
********* ajax = createAjax();
********* ajax.open("POST", "../cfiniquitos/doc_php/src/startsession.php", true);
********* ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
********* ajax.send("user_id="+this_objectUser);
********* ajax.onreadystatechange=function()
*** {
*** ***** if (ajax.readyState==4)
******* {
******* * if (ajax.status == 200)
******* * {
********* ******* *** var datagrid = ajax.responseXML.getElementsByTagName("user")[0];
********* ******* *** var user = datagrid.childNodes[0].data;
********* ******* *** alert(user);
********* ******* *** clared_txt();
********* ******* }
******* }
*** }
*********
}
*
*
y el codigo XML
*
date_default_timezone_set('America/Mexico_City');
include("../lib/db_connect.php");
$query_id = mysql_query("SELECT * FROM tbuser WHERE id_user = '15272874' AND password = '0'",$db_connect) or die ("Error #0001: Error query line (6)");
********* $xml="<?xml version='1.0' encoding='ISO-8859-1'?>";
*********
********* $user_name = mysql_result($query_id,0,"name");
********* $xml.="<user>";
********************* $xml.="<user_id><![CDATA[$user_name]]></user_id>";
********* $xml.="</user>";
header("Content-type: text/xml");
echo $xml;
  #2 (permalink)  
Antiguo 26/09/2011, 14:45
 
Fecha de Ingreso: noviembre-2010
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Error al recibir datos en ajax

Hola que tal amigos vengo con esta otra duda estoy tratando de recibir un dato por medio de un XML según yo todo esta bien pero me regresa un valor ‘undefined’
que es lo que pasa les incluyo el codigo AJAX

function createAjax()
{
var xmlhttp=false;
try
{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E) { xmlhttp=false; }
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }
return xmlhttp;
}

function login_ajax()
{
var this_objectUser = document.getElementById("txtUser");
var this_objectPass = document.getElementById("txtPassword");
ajax = createAjax();
ajax.open("POST", "../cfiniquitos/doc_php/src/startsession.php", true);
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("user_id="+this_objectUser);
ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
if (ajax.status == 200)
{
var datagrid = ajax.responseXML.getElementsByTagName("user")[0];
var user = datagrid.childNodes[0].data;
alert(user);
clared_txt();
}
}
}

}


y el codigo XML

date_default_timezone_set('America/Mexico_City');
include("../lib/db_connect.php");
$query_id = mysql_query("SELECT * FROM tbuser WHERE id_user = '15272874' AND password = '0'",$db_connect) or die ("Error #0001: Error query line (6)");
$xml="<?xml version='1.0' encoding='ISO-8859-1'?>";

$user_name = mysql_result($query_id,0,"name");
$xml.="<user>";
$xml.="<user_id><![CDATA[$user_name]]></user_id>";
$xml.="</user>";
header("Content-type: text/xml");
echo $xml;

Última edición por Lanix_0; 26/09/2011 a las 16:58

Etiquetas: ajax
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 10:33.