From 0e56669cc47f56a73e8c4246e1aca8d4bd92a599 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 30 Dec 2023 22:02:24 +0900 Subject: [PATCH] Show more detailed URL in AJAX error message --- common/js/xml_handler.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index ca85cc9dd..5adc8e2b1 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -211,6 +211,7 @@ window.exec_json = $.exec_json = function(action, params, callback_success, callback_error) { // Convert params to object and fill in the module and act. + var url = XE.URI(request_uri).pathname(); var action_parts = action.split('.'); var request_info; if (action === 'raw') { @@ -307,22 +308,22 @@ // Otherwise, display a simple alert dialog. if ($(".x_modal-body").size()) { if (xhr.status == 0) { - error_info = 'Connection failed: ' + xhr.statusText + " (" + textStatus + ")" + "

" + xhr.responseText + "
"; + error_info = 'Connection failed: ' + url + ' (' + textStatus + ')' + "

" + xhr.responseText + "
"; } else { error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "

" + xhr.responseText + "
"; } - msg = "AJAX communication error while requesting " + params.module + "." + params.act + "

" + error_info; + msg = "AJAX communication error while requesting " + (params.act ? (params.module + "." + params.act) : url) + "

" + error_info; console.error(msg.replace(/(
)+/g, "\n").trim()); if (window.show_ajax_errors.indexOf('ALL') >= 0 || window.show_ajax_errors.indexOf(xhr.status) >= 0) { alert(msg); } } else { if (xhr.status == 0) { - error_info = 'Connection failed: ' + xhr.statusText + " (" + textStatus + ")" + "\n\n" + xhr.responseText; + error_info = 'Connection failed: ' + url + ' (' + textStatus + ')' + "\n\n" + xhr.responseText; } else { error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")" + "\n\n" + xhr.responseText; } - msg = "AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info; + msg = "AJAX communication error while requesting " + (params.act ? (params.module + "." + params.act) : url) + "\n\n" + error_info; console.error(msg.trim().replace(/\n+/g, "\n")); if (window.show_ajax_errors.indexOf('ALL') >= 0 || window.show_ajax_errors.indexOf(xhr.status) >= 0) { alert(msg); @@ -344,7 +345,7 @@ $.ajax({ type: "POST", dataType: "json", - url: XE.URI(request_uri).pathname(), + url: url, data: params, processData: (action !== 'raw'), headers : headers,