Spaces:
Running
Running
Update index.html
Browse files- index.html +96 -19
index.html
CHANGED
@@ -1,19 +1,96 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>fetch api & Datatable</title>
|
8 |
+
|
9 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.2.0/css/bootstrap.min.css">
|
10 |
+
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css">
|
11 |
+
|
12 |
+
<style>
|
13 |
+
section{
|
14 |
+
position: relative;
|
15 |
+
width: 100%;
|
16 |
+
padding: 0px 8% 20px;
|
17 |
+
}
|
18 |
+
header h1{
|
19 |
+
color: #8e44ad;
|
20 |
+
font-size: 2em;
|
21 |
+
margin:30px 0px
|
22 |
+
}
|
23 |
+
|
24 |
+
</style>
|
25 |
+
</head>
|
26 |
+
<body>
|
27 |
+
|
28 |
+
<section>
|
29 |
+
<header>
|
30 |
+
<h1>Data table</h1>
|
31 |
+
</header>
|
32 |
+
|
33 |
+
<!-- table area -->
|
34 |
+
<table id="example" class="table table-striped" style="width:100%">
|
35 |
+
<thead>
|
36 |
+
<tr>
|
37 |
+
<th>Zone</th>
|
38 |
+
<th>Sr No</th>
|
39 |
+
<th>Name</th>
|
40 |
+
<th>Fathers Name</th>
|
41 |
+
<th>Mobile</th>
|
42 |
+
<th>Name_E</th>
|
43 |
+
<th>Father's Name E</th>
|
44 |
+
</tr>
|
45 |
+
</thead>
|
46 |
+
<tbody>
|
47 |
+
|
48 |
+
</tbody>
|
49 |
+
|
50 |
+
</table>
|
51 |
+
</section>
|
52 |
+
|
53 |
+
|
54 |
+
<!-- js library -->
|
55 |
+
|
56 |
+
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
|
57 |
+
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script>
|
58 |
+
<script src="https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js"></script>
|
59 |
+
|
60 |
+
|
61 |
+
<script>
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
fetch('http://basantagarwal.com/csvjson.json')
|
66 |
+
.then(res=>res.json())
|
67 |
+
.then(data=>{
|
68 |
+
console.log('data',data);
|
69 |
+
|
70 |
+
displayProducts(data);
|
71 |
+
})
|
72 |
+
|
73 |
+
async function displayProducts(products) {
|
74 |
+
let html = '';
|
75 |
+
await products.forEach((product, index, array) => {
|
76 |
+
html += '<tr>';
|
77 |
+
html += `<td>
|
78 |
+
${product.Zone}
|
79 |
+
</td>
|
80 |
+
<td>${product.SrNo}</td>
|
81 |
+
<td>${product.NAME}</td>
|
82 |
+
<td>${product.FATHERS_NAME}</td>
|
83 |
+
<td>${product.Mobile}</td>
|
84 |
+
<td>${product.NAME_E}</td>
|
85 |
+
<td>${product.FATHERSN_E}</td>`;
|
86 |
+
html += '</tr>';
|
87 |
+
})
|
88 |
+
document.querySelector('tbody').innerHTML = await html;
|
89 |
+
//
|
90 |
+
$(document).ready(function () {
|
91 |
+
$('#example').DataTable();
|
92 |
+
});
|
93 |
+
}
|
94 |
+
</script>
|
95 |
+
</body>
|
96 |
+
</html>
|