-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax-store.html
More file actions
85 lines (74 loc) · 3 KB
/
ajax-store.html
File metadata and controls
85 lines (74 loc) · 3 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Online Store</title>
</head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<style>
.tableCenter{
width: 45%;
float: none;
border: 1px solid black;
margin: 2em auto 0;
/*padding: 50*/
}
.button{
margin-left: 46%;
margin-top: 2em;
}
.background{
background: #6C939F}
</style>
<body class="container background mt-5">
<h1 class="text-center">My Tool Store</h1>
<table id="products" class="table table-border tableCenter blockquote shadow-lg p-3 mb-5 bg-white">
<thead>
<tr>
<th>Title</th>
<th>Quantity</th>
<th>Price</th>
<th>Categories</th>
</tr>
</thead>
<tbody id="insertProducts"></tbody>
</table>
<button id="button" class="button">click me</button>
<!--<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<!-- Your custom JS goes here -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
(function() {
"use strict";
$(document).ready(function() {
// TODO: Create an AJAX GET request for the file under data/inventory.json
$.get('../data/inventory.json').done(function (data) {
data.forEach(function (item) {
console.log(item)
$("#insertProducts").append(`<tr><td>${item.title}</td><td>${item.quantity}</td><td>${item.price}</td><td>${item.categories}</td></tr>`)
});
console.log(data);
});
// TODO: Take the data from inventory.json and append it to the products table
// {
// type: "GET",
// dats
// {
// title:'hammer',
// }
// }
// 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>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.7/dist/umd/popper.min.js" integrity="sha384-zYPOMqeu1DAVkHiLqWBUTcbYfZ8osu1Nd6Z89ify25QV9guujx43ITvfi12/QExE" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.min.js" integrity="sha384-Y4oOpwW3duJdCWv5ly8SCFYWqFDsfob/3GkgExXKV4idmbt98QcxXYs9UoXAB7BZ" crossorigin="anonymous"></script>
</body>
</html>