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 61 62 63 64 65 66 67 68 69 70
|
<script type="text/javascript">
var urlBase = "http://localhost:8080/objectifmars-serveur";
var xhr = null;
var httpRequest1 = null;
function getXhr(){
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
return xhr;
}
xhr=getHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
//La réponse renvoyer par le serveur est du JSON
var jsonText = xhr.responseText;
//Je parse le flux JSON et je récupére les valeurs
var jsonObject = typeof JSON !='undefined' ? JSON.parse(jsonText) : eval('('+jsonText+')');
for(i=0;i<jsonObject.length;i++) {
//Je créer un tableau ou j'ajoute les détails de mes catégorie
for(var i = 0; i < 4; i++) {
switch (i) {
case 0:
row1.appendChild(url);
/*function articles(){
url1.href = url des articles que je récupére;
httpRequest.open('GET',url1,true);
httpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpRequest.send(null);
}
articles();*/
break;
case 1 :
row1.appendChild(idCommandes);
break;
case 2 :
row1.appendChild(dateDebut);
break;
case 3:
row1.appendChild(dateFin);
break;
//ensuite j'ajoute chaque row à mon tableau et le tableau dans un div..etc
}
}
}
}
}
}
var url = "http://localhost:8080/monProjet/commandes";
xhr.open('GET',url,true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send(null);
</script></head>
<body>
</body>
</html> |
Partager