lokeshloki143 commited on
Commit
0da1c37
·
verified ·
1 Parent(s): c4f7a3e

Update templates/cart.html

Browse files
Files changed (1) hide show
  1. templates/cart.html +9 -4
templates/cart.html CHANGED
@@ -1,3 +1,4 @@
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
@@ -274,12 +275,16 @@
274
  }
275
 
276
  function proceedToBill() {
277
- // Check redirect conditions before navigating to /bill
278
  fetch('/cart/validate_redirect', {
279
  method: 'GET',
280
  headers: { 'Content-Type': 'application/json' }
281
  })
282
- .then(response => response.json())
 
 
 
 
 
283
  .then(data => {
284
  if (data.success) {
285
  window.location.href = '/bill'; // Redirect only if conditions are met
@@ -291,8 +296,8 @@
291
  }
292
  })
293
  .catch(err => {
294
- console.error('Error validating redirect:', err);
295
- alert('An error occurred. Please try again.');
296
  });
297
  }
298
  </script>
 
1
+ <!只见此处需要添加一个代码块 - 代码语言:html
2
  <!DOCTYPE html>
3
  <html lang="en">
4
  <head>
 
275
  }
276
 
277
  function proceedToBill() {
 
278
  fetch('/cart/validate_redirect', {
279
  method: 'GET',
280
  headers: { 'Content-Type': 'application/json' }
281
  })
282
+ .then(response => {
283
+ if (!response.ok) {
284
+ throw new Error(`HTTP error! Status: ${response.status}, StatusText: ${response.statusText}`);
285
+ }
286
+ return response.json();
287
+ })
288
  .then(data => {
289
  if (data.success) {
290
  window.location.href = '/bill'; // Redirect only if conditions are met
 
296
  }
297
  })
298
  .catch(err => {
299
+ console.error('Error validating redirect:', err.message);
300
+ alert(`Failed to validate redirect: ${err.message}. Please check the console for details and try again.`);
301
  });
302
  }
303
  </script>