-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreservationsEnd.js
More file actions
34 lines (30 loc) · 1.12 KB
/
Copy pathreservationsEnd.js
File metadata and controls
34 lines (30 loc) · 1.12 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
/* global $ */
async function fetchAndPopulateTable() {
$.ajax({
type: "POST",
url: "http://localhost:5000/get_reservations",
success: function(response) {
if (response.status === "success") {
let reservations = response.reservations;
let tableBody = $("#reservations-table tbody");
reservations.forEach(item => {
let row = "<tr>";
row += `<td>${item[0]}</td>`;
row += `<td>${item[1]}</td>`;
row += `<td>${item[2]}</td>`;
row += `<td>${item[3]}</td>`;
row += `<td>${item[4]}</td>`;
row += `<td>${item[5]}</td>`;
row += "</tr>";
tableBody.append(row);
});
} else {
console.log("Error:", response.message);
}
},
error: function(xhr, status, error) {
console.error("Error:", error);
}
});
}
document.addEventListener('DOMContentLoaded', fetchAndPopulateTable);