1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
function ajax(){
//document.getElementById("titre_livre").innerHTML="youhou";
var xhr=null;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject){
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
//on définit l'appel de la fonction au retour serveur
xhr.onreadystatechange = function() { alert_ajax(xhr); };
//on appelle le fichier reponse.txt
xhr.open("GET", "reponse.php", true);
xhr.send(null);
}
function alert_ajax(xhr){
var docXML= xhr.responseXML;
var items = docXML.getElementsByTagName("donnee")
//on fait juste une boucle sur chaque element "donnee" trouvé
for (i=0;i<items.length;i++){
alert (items.item(i).firstChild.data);
}
} |