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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
coté client / AJAX :
var xhr = null;
function afficherAcheteur() {
if (xhr && xhr.readyState != 0) {
xhr.abort();
}
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
var tableau = xml2table(xhr.responseXML);
}
};
xhr.open("POST", "fichier/page/acheteur.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("action=afficher");
}
function xml2table(xml) {
var i =0;
var facture = '';
var table = '';
table += '<html:table id="tableauAcheteur">';
table += '<html:thead id="headTableuAcheteur">';
table += '<html:tr id="ligneHeadTableauAcheteur">';
table += '<html:td id="numAcheteurHeadTableauAcheteur">Numéro de l\'acheteur</html:td>';
table += '<html:td id="nomHeadTableauAcheteur">Nom</html:td>';
table += '<html:td id="prenomHeadTableauAcheteur">Prénom</html:td>';
table += '<html:td id="adresseHeadTableauAcheteur">Adresse</html:td>';
table += '<html:td id="codePostalHeadTableauAcheteur">Code postal</html:td>';
table += '<html:td id="villeHeadTableauAcheteur">Ville</html:td>';
table += '<html:td id=factureHeadTableauAcheteur">Facture</html:td>';
table += '</html:tr>';
table += '</html:thead>';
table += '<html:tbody id="bodyTableauAcheteur>';
while (numAcheteurs[i] != undefined) {
(xml.selectNodes("/vente/acheteur[" + i + "]/nom") == 0) ? facture = 'non' : facture = 'oui';
table += '<html:tr id="ligneBodyTableauAcheteur">';
table += '<html:td id="numAcheteurBodyTableauAcheteur>' + xml.selectNodes("/vente/acheteur[" + i + "]/numAcheteur") + '</html:td>';
table += '<html:td id="nomBodyTableauAcheteur">' + xml.selectNodes("/vente/acheteur[" + i + "]/nom") + '</html:td>';
table += '<html:td id="prenomBodyTableauAcheteur">' + xml.selectNodes("/vente/acheteur[" + i + "]/prenom") + '</html:td>';
table += '<html:td id="adresseBodyTableauAcheteur">' + xml.selectNodes("/vente/acheteur[" + i + "]/adresse") + '</html:td>';
table += '<html:td id="codePostalBodyTableauAcheteur">' + xml.selectNodes("/vente/acheteur[" + i + "]/codePostal") + '</html:td>';
table += '<html:td id="villeBodyTableauAcheteur">' + xml.selectNodes("/vente/acheteur[" + i + "]/ville") + '</html:td>';
table += '<html:td id="factureBodyTableauAcheteur">' + facture + '</html:td>';
table += '</html:tr>';
}
table += '</html:tbody>';
table += '</html:table>';
return table;
} |
Partager