-
Notifications
You must be signed in to change notification settings - Fork 0
/
20240116-Read.html
67 lines (65 loc) · 2.31 KB
/
20240116-Read.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
60
61
62
63
64
65
66
67
<!-- 資料的顯示,用table顯示,有使用【20240116-Read.php】 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>串接資料練習-Read</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/myall.css">
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<table class="table table-bordered mt-3">
<thead class="table-dark">
<tr>
<th>商品編號</th>
<th>商品品名</th>
<th>商品價格</th>
<th>商品數量</th>
<th>商品備註</th>
<th>建檔時間</th>
</tr>
</thead>
<tbody id="mybody">
<tr>
<td>XX</td>
<td>XX</td>
<td>XX</td>
<td>XX</td>
<td>XX</td>
<td>XX</td>
</tr>
</tbody>
</tabele>
</div>
</div>
</div>
<script src="js/bootstrap.bundle.min.js"></script>
<script src="js/jquery-3.7.1.min.js"></script>
<script>
$(function(){
$.ajax({
type: "GET",
url: "20240116-Read.php",
dataType: "json",
success: showdata,
error: function(){
alert("串接資料錯誤!");
}
});
});
function showdata(data){
console.log(data.data);
$("#mybody").empty();
data.data.forEach(function(item){
console.log(item.Product);
var strHTML = '<tr><td>' + item.ID + '</td><td>' + item.Product + '</td><td>' + item.Price + '</td><td>' + item.Num + '</td><td>' + item.Remark + '</td><td>' + item.Created_at + '</td></tr>';
$("#mybody").append(strHTML);
});
}
</script>
</body>
</html>