1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 $(document).on('ajax:error', function(e, xhr, status, error) {
6 var errorMessage = '' + status + ': ' + error;
7 // $btn is the element (button/link) that initiated the failed request.
8 var $btn = $(e.target);
9 // Populate some elements with the error text (e.g., a <p> in an alert div)
10 $($btn.attr('data-on-error-write')).text(errorMessage);
11 // Show some elements (e.g., an alert div)
12 $($btn.attr('data-on-error-show')).show();
13 // Hide some elements (e.g., a success/normal div)
14 $($btn.attr('data-on-error-hide')).hide();
15 }).on('ajax:success', function(e) {
16 var $btn = $(e.target);
17 $($btn.attr('data-on-success-show')).show();
18 $($btn.attr('data-on-success-hide')).hide();