-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
53 lines (50 loc) · 1.5 KB
/
index.html
File metadata and controls
53 lines (50 loc) · 1.5 KB
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
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
</head>
<body>
<header></header>
<main>
<div id="affichage"></div>
</main>
<footer>
<script type="text/javascript">
let div = document.getElementById('affichage');
function getPeople() {
let req = new XMLHttpRequest();
req.open("GET", "people.php", true);
req.onload= function(){
if (this.status == 200) {
div.innerHTML += '<div style="display: flex; flex-direction: row; flex-wrap: wrap">';
for (let i = 0; i < this.responseXML.getElementsByTagName('human').length; i++) {
let auteur = this.responseXML.getElementsByTagName('human')[i].getElementsByTagName('pseudo')[0].firstChild.data;
getImg(auteur);
}
div.innerHTML += '</div>';
} else {
console.error('error');
}
};
req.send(null);
}
function getImg(auteur) {
let req1 = new XMLHttpRequest();
req1.open("POST", "human.php", true);
req1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req1.onload = function() {
if (this.status == 200) {
let url = this.responseXML.getElementsByTagName('human')[0].getElementsByTagName('url')[0].firstChild.data;
div.innerHTML += '<img src="' + url + '" style="width: 100px; height: 100px">';
} else {
console.error('error');
}
};
req1.send('auteur=' + auteur);
}
getPeople();
</script>
</footer>
</body>
</html>