diff --git a/share/public/javascripts/netdisco.js b/share/public/javascripts/netdisco.js
index 1a5030c6..6018997b 100644
--- a/share/public/javascripts/netdisco.js
+++ b/share/public/javascripts/netdisco.js
@@ -30,29 +30,64 @@ function do_search (event, tab) {
);
// submit the query and put results into the tab pane
- $(target).load( uri_base + '/ajax/content/' + path + '/' + tab + '?' + query,
- function(response, status, xhr) {
- if (status !== "success") {
+ fetch( uri_base + '/ajax/content/' + path + '/' + tab + '?' + query,
+ { headers: { 'X-Requested-With': 'XMLHttpRequest' } })
+ .then( response => {
+ if (! response.ok) {
$(target).html(
'
' +
- 'Search failed! Please contact your site administrator.
'
+ 'Search failed! Please contact your site administrator (server error).'
);
return;
+ // throw new Error('Network response was not ok');
}
- if (response == "") {
- $(target).html(
- 'No matching records.
'
- );
+ return response.text();
+ })
+ .then( content => {
+ if (content == "") {
+ $(target).html('No matching records.
');
}
+ else {
+ $(target).html(content);
+ // delegate to any [device|search] specific JS code
+ $('div.content > div.tab-content table.nd_floatinghead').floatThead({
+ scrollingTop: 40
+ ,useAbsolutePositioning: false
+ });
+ inner_view_processing(tab);
+ }
+ })
+ .catch( error => {
+ $(target).html(
+ ' ' +
+ 'Search failed! Please contact your site administrator (network error: ' + error + ').
'
+ );
+ console.error('There has been a problem with your fetch operation:', error);
+ });
- // delegate to any [device|search] specific JS code
- $('div.content > div.tab-content table.nd_floatinghead').floatThead({
- scrollingTop: 40
- ,useAbsolutePositioning: false
- });
- inner_view_processing(tab);
- }
- );
+// $(target).load( uri_base + '/ajax/content/' + path + '/' + tab + '?' + query,
+// function(response, status, xhr) {
+// if (status !== "success") {
+// $(target).html(
+// ' ' +
+// 'Search failed! Please contact your site administrator.
'
+// );
+// return;
+// }
+// if (response == "") {
+// $(target).html(
+// 'No matching records.
'
+// );
+// }
+//
+// // delegate to any [device|search] specific JS code
+// $('div.content > div.tab-content table.nd_floatinghead').floatThead({
+// scrollingTop: 40
+// ,useAbsolutePositioning: false
+// });
+// inner_view_processing(tab);
+// }
+// );
}
// keep track of which tabs have a sidebar, for when switching tab