diff options
author | Frederick Muriuki Muriithi | 2022-05-26 13:41:22 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-05-26 13:42:05 +0300 |
commit | e71d2c5d35771645a85a5e0fa7ebdfca4809a16b (patch) | |
tree | 3fc65811f5b362b07a289c433e99656a59a4c7ba | |
parent | 4c1da58232632eb590d2a1830723e87b1d7bb638 (diff) | |
download | genenetwork2-e71d2c5d35771645a85a5e0fa7ebdfca4809a16b.tar.gz |
Indicate error if system in unable to fetch menu
-rw-r--r-- | wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index 1d4a94d9..7a67a017 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -7,9 +7,28 @@ process_json = function(data) { } }; +indicate_error = function (jqXHR, textStatus, errorThrown) { + console.error(jqXHR); + console.error(textStatus); + console.error(errorThrown); + errorElement = document.createElement("span"); + errorElement.setAttribute("class", "alert-danger"); + errorText = document.createTextNode( + "There was an error retrieving and setting the menu. Try again later."); + errorElement.appendChild(errorText); + form = document.getElementById("search").getElementsByTagName("form")[0]; + form.prepend(errorElement); + disable_element = function(select) { + select.setAttribute("disabled", "disabled"); + }; + Array.from(form.getElementsByTagName("select")).forEach(disable_element); + Array.from(form.getElementsByTagName("textarea")).forEach(disable_element); +}; + $.ajax('/api/v_pre1/gen_dropdown', { - dataType: 'json', - success: process_json + dataType: 'json', + success: process_json, + error: indicate_error }); populate_species = function() { |