-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex1.html
59 lines (57 loc) · 1.77 KB
/
index1.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="jumbotron">
<h4>My Ajax and Api Lesson</h4>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Photo</th>
<th>Name</th>
<th>Phone</th>
<th>Street</th>
<th>Quarter</th>
</tr>
</thead>
<tbody id="showDrivers"></tbody>
</table>
</div>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script>
$(()=>{
getDrivers();
function getDrivers() {
$.ajax({
type:"get",
url:"drivers_api.php",
success:function (res) {
$.each(res,(i,d)=>{
//console.log(d)
$("#showDrivers")
.append('<tr><td>'+d.id+'</td><td class="col-sm-2"><img class="img-thumbnail" src="drivers/'+d.photo+'"></td><td>'+d.driver_name+'</td><td>'+d.phone+'</td><td>'+d.street_name+'</td><td>'+d.quarter_name+'</td></tr>')
})
/*res.map((d)=>{
console.log(d)
})*/
},
error:function (err) {
console.log(err)
}
})
}
})
</script>
</body>
</html>