From 6861a6dd9752872f281b1817a45d024006323767 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Thu, 23 Jul 2020 22:31:12 +1000 Subject: [PATCH] Show error message when preview fails --- wikinote/static/js/page.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wikinote/static/js/page.js b/wikinote/static/js/page.js index bf634c3..bb688b0 100644 --- a/wikinote/static/js/page.js +++ b/wikinote/static/js/page.js @@ -23,7 +23,11 @@ document.querySelectorAll('.tooltip.xref').forEach(function(el) { var xhr = new XMLHttpRequest(); xhr.addEventListener('load', function() { - el.querySelector('.tooltip-content').innerHTML = xhr.responseText; + if (xhr.status == 200) { + el.querySelector('.tooltip-content').innerHTML = xhr.responseText; + } else { + el.querySelector('.tooltip-content').innerHTML = 'Error'; + } }) xhr.open('GET', '/preview/' + el.dataset['xref']); xhr.send();