lokesh341 commited on
Commit
8c3b9dc
·
verified ·
1 Parent(s): 09e6ccc

Update templates/menu_page.html

Browse files
Files changed (1) hide show
  1. templates/menu_page.html +6 -5
templates/menu_page.html CHANGED
@@ -1,4 +1,3 @@
1
-
2
  <!DOCTYPE html>
3
  <html lang="en">
4
  <head>
@@ -60,13 +59,14 @@
60
  </div>
61
 
62
  <script>
 
63
  function fetchMenu() {
64
- fetch("/menu") // Fetching menu from Flask API
65
- .then(response => response.json())
66
  .then(data => {
67
  if (data.success) {
68
  let menuContainer = document.getElementById("menu-list");
69
- menuContainer.innerHTML = "";
70
 
71
  data.menu.forEach(item => {
72
  let menuItem = document.createElement("div");
@@ -92,12 +92,13 @@
92
  });
93
  }
94
 
 
95
  function addToCart(name, price) {
96
  alert(`${name} added to cart!`);
97
  }
98
 
 
99
  window.onload = fetchMenu;
100
  </script>
101
  </body>
102
  </html>
103
-
 
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
 
59
  </div>
60
 
61
  <script>
62
+ // ✅ Fetch Menu from Flask API
63
  function fetchMenu() {
64
+ fetch("/menu") // Calls Flask API
65
+ .then(response => response.json()) // Convert response to JSON
66
  .then(data => {
67
  if (data.success) {
68
  let menuContainer = document.getElementById("menu-list");
69
+ menuContainer.innerHTML = ""; // Clear previous content
70
 
71
  data.menu.forEach(item => {
72
  let menuItem = document.createElement("div");
 
92
  });
93
  }
94
 
95
+ // ✅ Function to Add Items to Cart (Simple Alert for Now)
96
  function addToCart(name, price) {
97
  alert(`${name} added to cart!`);
98
  }
99
 
100
+ // ✅ Call API on Page Load
101
  window.onload = fetchMenu;
102
  </script>
103
  </body>
104
  </html>