Bug 24084 - PlainMARC view broken on OPAC if other $.ajax calls produce errors
Summary: PlainMARC view broken on OPAC if other $.ajax calls produce errors
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-21 18:17 UTC by Lucas Gass
Modified: 2021-06-14 21:29 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00


Attachments
Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors (4.24 KB, patch)
2019-11-21 18:29 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors (4.29 KB, patch)
2019-11-21 18:36 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors (4.34 KB, patch)
2019-11-22 21:43 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass 2019-11-21 18:17:35 UTC
There is a problem with the how the #plainmarc div is loaded on opac-MARCdetail.pl. If there is an unrelated AJAX error you will always see the "Sorry, plain view is temporarily unavailable".

To Test:

1. Make a unrelated AJAX request that would produce an error. I added this to the OPACUSERJS: 

$(document).ready(function () {
  $.ajax({url: "thisURLwontWork.html", success: function(result){
    console.log('Just Making an error')
  }});
});

2. Go to opac-MARCdetail.pl and notice plainmarc will not load and you will see the "Sorry, plain view is temporarily unavailable" message.
Comment 1 Owen Leonard 2019-11-21 18:29:01 UTC Comment hidden (obsolete)
Comment 2 Lucas Gass 2019-11-21 18:36:26 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2019-11-22 21:43:42 UTC
Created attachment 95749 [details] [review]
Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors

This patch removes the use of jQuery's ajaxSetup() and load() to get the
"plain" MARC view and replaces it with $.get(). This allows for
error-handling on this specific AJAX request rather than all on the
page.

To test, apply the patch and view a bibliographic record in the OPAC.

 - Click the "MARC view" tab.
 - Click the "view plain" link.
  - The plain-text MARC view should load.
  - Clicking "view labeled" should return you to the original view.

To test error handling, edit opac-MARCdetail.tt line 185 and add a typo
to the URL, e.g. "opac-showmark.pl." Repeat the above steps. Clicking
the "view plain" link should trigger an error message: "Sorry, plain
view is temporarily unavailable."

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 4 Martin Renvoize 2019-11-25 08:44:03 UTC
Nice work!

Pushed to master for 19.11.00