Bonjour,
J'ai besoin de faire un apel Ajax pour reprendre des données d'une bdd. Sans problème, je fait cela. Quand mon xhr change d'état, j'appel la fonction suivante (xhr est donc un élément XMLHttpRequest()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| function arrayFromXML(xhr)
{
var tab = new Array();
if (xhr.readyState==4)
{
if (xhr.status==200)
{
var array = xhr.responseXML.firstChild.childNodes;
for(var i = array.length - 1 ; i >=0; i--)
{
tab[array[i].getAttribute("type")]=array[i].getAttribute["value"];
}
}
}
return tab;
} |
mais voila, tabe est vide. j'avoue que c'est obscure pour moi. est ce que qqun serait pourquoui tab est vide ?
PS : mon apel XHR renvoi un XML de type :
<racine>
<element type="toto" value="prout" />
</racine>
Partager