Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   Javascript (http://www.forosdelweb.com/f13/)
-   -   Problemas con al crear elementos DOM en IE7 (http://www.forosdelweb.com/f13/problemas-con-crear-elementos-dom-ie7-592886/)

Markcoz 03/06/2008 09:02

Problemas con al crear elementos DOM en IE7
 
que tal tengo el sig. problema tengo una funcion con ajax que me genera un listado de la bse de datos, hasta ahi todo bien funciona perfecto en ie6, el problema es que al probarlo con ie7 ya no funciona, no me marca error pero simplemente no me muestra los datos. el codigo es el siguiente:

for (i = 0; i < xml.getElementsByTagName('factura').length; i++){
entro = true;
var ite = xml.getElementsByTagName('factura')[i];
var id = ite.getElementsByTagName('id')[0].firstChild.data;
var fecha = ite.getElementsByTagName('fecha')[0].firstChild.data;
var nFactura = ite.getElementsByTagName('nFactura')[0].firstChild.data;
var cliente = ite.getElementsByTagName('cliente')[0].firstChild.data;
var importe = ite.getElementsByTagName('importe')[0].firstChild.data;


var row = document.createElement("tr");
var cldChk = document.createElement("td");
var cldId= document.createElement("td");
var cldFecha= document.createElement("td");
var cldFactura= document.createElement("td");
var cldCliente= document.createElement("td");
var cldImporte= document.createElement("td");


cldChk.innerHTML = "<input type='checkbox' name='rd_factura' value="+id+" onClick='sumaFactura(this)'>";
cldId.innerHTML = + id ;
cldFecha.innerHTML = fecha ;
cldFactura.innerHTML = nFactura ;
cldCliente.innerHTML = cliente;
cldImporte.innerHTML = importe ;

row.appendChild(cldChk);
row.appendChild(cldFecha);
row.appendChild(cldFactura);
row.appendChild(cldCliente);
row.appendChild(cldImporte);

myTable.appendChild(row);

} // for

ese es el codigo con el que recupero la informacion del xml creado, el problema es que con ie7 nunca entra al ciclo para recuperar la info, si alguiente tiene idea de porque y me lo dice se los agradeceria

GatorV 03/06/2008 09:51

Respuesta: Problemas con ie7 y ajax
 
Tu problema ya es al parsear los datos, no en tanto en AJAX. Te muevo al foro de Javascript para que te asesoren correctamente.

Saludos.

Panino5001 03/06/2008 10:09

Respuesta: Problemas con al crear elementos DOM en IE7
 
Considerando que funcionaba bien en explorer 6, en realidad no creo que el problema sea el parser. Deberías revisar el content-type de tu archivo xml (debe ser text/xml) y el response body, para asegurarte, en caso de que sea un xml dinámico, que se genera correctamente (me ha pasado en explorer 7 y con xmls dinámicos que algunos caracteres (acentos o espacios) en el querystring generaban un error al tomar una fuente y el xml se rompía, cosa que no pasaba en firefox). Te sugiero uses DebugBar, que es algo así como firebug pero para explorer.

Markcoz 03/06/2008 17:05

Respuesta: Problemas con al crear elementos DOM en IE7
 
ps te comento todo esta bien si tengo el content type, cuando genero el xml, aunq se genera de manera dinamica, se cre perfectamente, el problema creo yo es al hacer el parser o algo asi

Markcoz 04/06/2008 07:27

Respuesta: Problemas con al crear elementos DOM en IE7
 
<?xml version="1.0" encoding="iso-8859-1" ?>
- <xml>
- <factura>
<id>42</id>
<fecha>2008-05-11</fecha>
<nFactura>F0001</nFactura>
<cliente>Clinica S. de R.L. de C.V.</cliente>
<importe>$509.00</importe>
<pago>$9.00</pago>
<saldo>500.0</saldo>
<fechaVencimiento>2008-05-28</fechaVencimiento>
<saldoFormato>$500.00</saldoFormato>
</factura>
- <factura>
<id>43</id>
<fecha>2008-05-11</fecha>
<nFactura>F0002</nFactura>
<cliente>Clinica S. de R.L. de C.V.</cliente>
<importe>$345.00</importe>
<pago>$0.00</pago>
<saldo>345.0</saldo>
<fechaVencimiento>2008-05-22</fechaVencimiento>
<saldoFormato>$345.00</saldoFormato>
</factura>
</xml>

Ese es el codigo xml que se genera aunq en el codigo q genera el documento tengo el contenttype="text/xml" no aparece al crear el doc xml, no se si sea por ahi el problema o cual

Panino5001 04/06/2008 07:51

Respuesta: Problemas con al crear elementos DOM en IE7
 
Probaste con ese xml, pero estático? Es decir, que el responseXML provenga de la consulta a una página que sólo tenga ese xml?
Otra cosa: myTable.nodeName es table o tbody?

Markcoz 04/06/2008 08:37

Respuesta: Problemas con al crear elementos DOM en IE7
 
Ps si ya lo probe estatico y el resultado es el mismo me regresa 0 elemtentos, en relacion al " myTable.nodeName " es tbody....

Panino5001 04/06/2008 10:01

Respuesta: Problemas con al crear elementos DOM en IE7
 
Probé esto con ese xml (lo llamé data.xml) y funciona perfectamente en Explorer 7 y el resto de los navegadores que probé:
Código PHP:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title></title>
<
script>
function $(
id){
    return 
document.getElementById(id);    
}
function 
http(){
     if(
window.XMLHttpRequest){
        return new 
XMLHttpRequest();
    }else{
        try{
            return new 
ActiveXObject('Microsoft.XMLHTTP');
        }catch(
e){
            
alert('Su navegador no soporta AJAX');
            return 
false;
        }
    }
}
function 
mostrar(){
    
H=new http();
    if(!
H)return;
    
H.open('get','data.xml',true);
    
H.onreadystatechange=function(){
        if(
H.readyState==4){
            try{
                var 
nodos=H.responseXML;
                
tabular(nodos);
            }catch(
e){
                
alert('problema al acceder a la información xml')
            }
            try{
                
H.abort();
                
H.onreadystatechange=null;
            }catch(
e){}
        }else{
            
document.getElementsByTagName('body')[0].innerHTML='cargando...';
        }
    }
    
H.send(null);
}
function 
tabular(xml){
    var 
Table=document.createElement('table');
    var 
myTable=document.createElement('tbody');

for (
0xml.getElementsByTagName('factura').lengthi++){
entro true;
var 
ite xml.getElementsByTagName('factura')[i];
var 
id ite.getElementsByTagName('id')[0].firstChild.data;
var 
fecha ite.getElementsByTagName('fecha')[0].firstChild.data;
var 
nFactura ite.getElementsByTagName('nFactura')[0].firstChild.data;
var 
cliente ite.getElementsByTagName('cliente')[0].firstChild.data;
var 
importe ite.getElementsByTagName('importe')[0].firstChild.data;


var 
row document.createElement("tr");
var 
cldChk document.createElement("td");
var 
cldIddocument.createElement("td");
var 
cldFechadocument.createElement("td");
var 
cldFacturadocument.createElement("td");
var 
cldClientedocument.createElement("td");
var 
cldImportedocument.createElement("td");


cldChk.innerHTML "<input type='checkbox' name='rd_factura' value="+id+" onclick='sumaFactura(this)'>";
cldId.innerHTML = + id ;
cldFecha.innerHTML fecha ;
cldFactura.innerHTML nFactura ;
cldCliente.innerHTML cliente;
cldImporte.innerHTML importe ;

row.appendChild(cldChk);
row.appendChild(cldFecha);
row.appendChild(cldFactura);
row.appendChild(cldCliente);
row.appendChild(cldImporte);
myTable.appendChild(row);
}

Table.appendChild(myTable);
document.getElementsByTagName('body')[0].innerHTML='';
document.getElementsByTagName('body')[0].appendChild(Table);

window.onload=mostrar;
</script>
</head>

<body>
</body>
</html> 



La zona horaria es GMT -6. Ahora son las 07:41.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.