Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/08/2008, 09:17
guzmange
 
Fecha de Ingreso: mayo-2008
Mensajes: 43
Antigüedad: 16 años
Puntos: 0
Que puede estar mal ?

Que puede estar mal de lo siguiente? OBJECT REQUIRED es el error en la linea donde tengo var respuesta=ajax.responseXML;

Código:
<?php
//header("Content-Type:text/xml;charset=UTF-8");
session_start();?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html+xml; charset=utf-8" />
<script language="javascript" type="text/javascript">
function nuevoAjax(){
 //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(); 
	// xmlhttp.overrideMimeType('text/xml');
	 } 
    return xmlhttp
}
function traerDatos()
{
    var _cod=document.getElementById("cod");
	_cod = _cod.value;
	//alert (cod);
    var campo1=document.getElementById("c1");
    var campo2=document.getElementById("c2");
	var campo3=document.getElementById("c3");
    var campo4=document.getElementById("c4");   
	var campo5=document.getElementById("c5"); 
    var campo6=document.getElementById("c6"); 
	var ajax=nuevoAjax();
    ajax.open("POST", "ej2.php", true);
    ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded charset=ISO-8859-1');
//	alert(cod);
	ajax.send("v="+_cod);           
	ajax.onreadystatechange=function()
	//alert(ajax.send());
    {
	
        if (ajax.readyState == 4)
        {
		  var respuesta=ajax.responseXML;
		  
			//var respuesta2=ajax.responseText;
			//alert(respuesta2);
			//alert (respuesta);
            campo1.value=respuesta.getElementsByTagName('nombre')[0].firstChild.nodeValue;
            campo2.value=respuesta.getElementsByTagName("apellido")[0].firstChild.nodeValue;
			campo3.value=respuesta.getElementsByTagName("ci")[0].firstChild.nodeValue;
            campo4.value=respuesta.getElementsByTagName("codigo")[0].firstChild.nodeValue;
            campo5.value=respuesta.getElementsByTagName("mails")[0].firstChild.nodeValue;
			campo6.value=respuesta.getElementsByTagName("tel")[0].firstChild.nodeValue;
			alert(campo1.value);
		}
    }
}
</script>