J'ai été un peu vite , la fenêtre "alerte" me retourne bien la valeur 1 pour var. Ca marche.
A présent, je voudrai tout intégrer dans une ligne mais ça ne fonctionne pas, je pense avoir un pb de syntaxe quelque part :
document.getElementById('LED').innerHTML = '<img src="LED' + getXMLValue(xmlData, 'var') +'.gif</img>">';
Voici la fonction getXMLValue :
1 2 3 4 5 6 7 8 9 10 11
| // Parses the xmlResponse returned by an XMLHTTPRequest object
// xmlData: the xmlData returned
// field: the field to search for
function getXMLValue(xmlData, field) {
try {
if(xmlData.getElementsByTagName(field)[0].firstChild.nodeValue)
return xmlData.getElementsByTagName(field)[0].firstChild.nodeValue;
else
return null;
} catch(err) { return null; }
} |
Partager