From d4d9aec2d2455e0847ea28a05182b1360a7cfc3b Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Wed, 20 Nov 2024 07:07:21 -0500 Subject: [PATCH] handle error 500 in ajax request --- app/javascript/application.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/javascript/application.js b/app/javascript/application.js index f62206c..fad75b4 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -8,6 +8,11 @@ $(document).ready(function () { $('.datepicker').datepicker(); if ($('#overview_fees_container').length > 0) { - $.getScript('/alma/reload_fees.js'); + $.getScript('/alma/reload_fees.js').fail(function( jqxhr, settings, exception ) { + var error = '

' + exception + '

'; + var reload = '

Reload

'; + var html = error + reload; + $('#overview_fees_container').empty().append(html); + }); } });