From 4767eb3a4fa57645dce0546b46b44d14455d04f3 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 2 Mar 2023 09:56:09 +1100 Subject: [PATCH] JS fixes for when we get a 419 --- public/js/custom.js | 17 +++++++++++++++-- .../layouts/partials/sidebarmenu.blade.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/public/js/custom.js b/public/js/custom.js index 38ae6ef..5bc66b1 100644 --- a/public/js/custom.js +++ b/public/js/custom.js @@ -42,8 +42,21 @@ $(document).ready(function() { }).done(function(html) { $('.main-content').empty().append(html); - }).fail(function() { - alert('Failed'); + }).fail(function(item) { + switch(item.status) { + case 404: + $('.main-content').empty().append(item.responseText); + break; + case 419: + alert('Session has expired, reloading the page and try again...'); + location.reload(); + break; + case 500: + $('.main-content').empty().append(item.responseText); + break; + default: + alert(item.status+': Well that didnt work?'); + } }); } }, diff --git a/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php b/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php index c20b0cc..97f2f8d 100644 --- a/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php +++ b/resources/themes/architect/views/layouts/partials/sidebarmenu.blade.php @@ -80,7 +80,7 @@ $('.main-content').empty().append(html); }).fail(function() { - //alert('Failed'); + alert('Well that didnt work?'); }); e.stopPropagation();