diff options
-rw-r--r-- | backend.php | 2 | ||||
-rw-r--r-- | js/reader.js | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/backend.php b/backend.php index e245fb2..6318853 100644 --- a/backend.php +++ b/backend.php @@ -290,6 +290,8 @@ array_push($result, "No results for: <b>$orig_word</b>"); print json_encode(["result" => $result]); + } else { + print json_encode(["result" => ["Dictionary lookups are disabled."]]); } break; diff --git a/js/reader.js b/js/reader.js index e71d157..99ff269 100644 --- a/js/reader.js +++ b/js/reader.js @@ -941,15 +941,21 @@ const Reader = { lookupWord: function(word, callback) { word = word.replace(//g, ""); + $(".dict_result").html('Loading, please wait...'); + + $("#dict-modal").modal('show'); + $.post("backend.php", {op: 'define', word: word}, function (data) { if (data) { $(".dict_result").html(data.result.join("<br/>")); $(".dict_query").val(word); - $("#dict-modal").modal('show'); if (callback) callback(); } + }).fail(function(res) { + console.warn(res); + $(".dict_result").html('Network error while looking up word: ' + res.statusText); }); }, search: function() { |