Skip to content

Commit

Permalink
Merge pull request #845 from tobser/ia7_catch_ajax_error
Browse files Browse the repository at this point in the history
Always show error message on failed ajax requests
  • Loading branch information
hplato authored Sep 18, 2022
2 parents 919bda9 + e14f55f commit de0b89e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/ia7/include/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2257,9 +2257,15 @@ var ajax_req_error = function(xhr, status, error, module, modal) {
if (xhr == undefined || xhr.responseText == undefined || xhr.responseText == "") {
message = "Lost communication with server";
} else {
var data = JSON.parse(xhr.responseText);
message = "Communication problem with server";
if (data !== undefined && data.text !== undefined) message = data.text;
try{
var data = JSON.parse(xhr.responseText);
if (data !== undefined && data.text !== undefined) message = data.text;
}
catch
{
message += `: ${xhr.status} - ${xhr.statusText}`;
}
}
console.log("Ajax Error! module="+module+" status="+status+" error="+error+" msg="+message);

Expand Down

0 comments on commit de0b89e

Please sign in to comment.