-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax-store.html
More file actions
68 lines (46 loc) · 1.74 KB
/
ajax-store.html
File metadata and controls
68 lines (46 loc) · 1.74 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
59
60
61
62
63
64
65
66
67
68
<html><head>
<title>Online Store</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<body data-new-gr-c-s-check-loaded="14.1093.0" data-gr-ext-installed="">
<h1>My Tool Store</h1>
<table id="products" class="table table-striped table-bordered border-dark">
<thead>
<tr>
<th>Title</th>
<th>Quantity</th>
<th>Price</th>
<th>Categories</th>
</tr>
</thead>
<tbody id="insertProducts"></tbody>
</table>
<button onClick="window.location.reload();">Refresh</button>
<script src="./js/jquery-3.6.3.js"></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)
{
let html = '';
$('#insertProducts').html('');
for(let i = 0; i < data.length; i++)
{
html += ` <tr>
<td>${data[i].title}</td>
<td>${data[i].quantity}</td>
<td>$${data[i].price}</td>
<td>${data[i].categories.join(' , ')}</td>
</tr>`
}
$('#insertProducts').html(html);
});
// 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>
</body><grammarly-desktop-integration data-grammarly-shadow-root="true"></grammarly-desktop-integration></html>