From ad66b8abc923c374e59363a1a542b89354a548d7 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 7 Apr 2018 11:37:23 -0500 Subject: [PATCH] common.js: show error on ajax failures. Make `link_to ..., remote: true` ajax requests display an error notice on failure. --- app/assets/javascripts/common.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index cbec48d0b..2b345a26d 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -39,6 +39,11 @@ $(function() { location.reload(); }); }); + + // triggered by rails when a `link_to ..., remote: true` call fails. + $(document).on("ajax:error", function (event, xhr, status, error) { + Danbooru.error("Error: " + xhr.status + " " + xhr.statusText); + }); }); var Danbooru = {};