-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax-store.html
More file actions
58 lines (41 loc) · 1.65 KB
/
ajax-store.html
File metadata and controls
58 lines (41 loc) · 1.65 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
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<title>Online Store</title>
</head>
<body class="bg-warning font-weight-bold">
<h1 class="fancy-header">My Tool Store</h1>
<table id="products">
<thead>
<tr class="">
<th>Title</th>
<th>Quantity</th>
<th>Price</th>
<th>Categories</th>
</tr>
</thead>
<tbody id="insertProducts"></tbody>
</table>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script>
(function() {
"use strict";
// TODO: Create an AJAX GET request for the file under data/inventory.json
$.get("/data/inventory.json").done(function(data) {
$("#insertProducts").html("");
data.forEach(function(data) {
let td = "<tr><td>" + data.title + "</td>"+
"<td>" + data.quantity + "</td>" + "<td>" + data.price + "</td>" + "<td>" + data.categories + "</td></tr>";
$('#products').append(td);
})
})
// TODO: Take the data from inventory.json and append it to the products table
// HINT: Your data should come back as a JSON object; use console.log() to inspect
// its contents and fields
// HINT: You will want to target #insertProducts for your new HTML elements
})();
</script>
<button class="btn-primary" onClick="window.location.reload();">Refresh Page</button>
</body>
</html>