Skip to content

Commit e91e594

Browse files
committed
Explain why we have two script text converters
Define two script converters: 1) script - This is the original converter to evaluate scripts for successful responses. 2) miq_script - Define a duplicate but differently named script converter whose purpose is to evaluate scripts for unsuccessful ajax responses. jQuery 3.5.0 changed the behavior of the script converter, replacing it with a no-op converter for scripts found in unsuccessful ajax responses. Successful responses would continue to be evaluated as previously. See: jquery/jquery@da3dd85 Due to this change starting in 3.5.0, we define a new type of script we can set as the dataType so it's evaluated in the event of unsuccessful responses such as the SSO 401 unauthorized issue we attempted to fix in #9410 and subsequently completed in #9426. [skip ci]
1 parent 9a1321c commit e91e594

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/javascript/oldjs/jquery_overrides.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ jQuery.jsonPayload = function(text, fallback) {
2424
};
2525

2626
$.ajaxSetup({
27+
/* Define two script converters:
28+
29+
1) script - This is the original converter to evaluate scripts for successful responses.
30+
2) miq_script - Define a duplicate but differently named script converter whose purpose is to
31+
evaluate scripts for unsuccessful ajax responses. jQuery 3.5.0 changed the behavior of the script
32+
converter, replacing it with a no-op converter for scripts found in unsuccessful ajax responses.
33+
Successful responses would continue to be evaluated as previously.
34+
See: https://github.com/jquery/jquery/commit/da3dd85b63c4e3a6a768132c2a83a1a6eec24840
35+
36+
Due to this change starting in 3.5.0, we define a new type of script we can set as the dataType
37+
so it's evaluated in the event of unsuccessful responses such as the SSO 401 unauthorized
38+
issue we attempted to fix in #9410 and subsequently completed in #9426.
39+
*/
2740
accepts: {
2841
json: 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript',
2942
},

0 commit comments

Comments
 (0)