Skip to content

Commit

Permalink
Get rid of Ajax.Request in favour of plain JS
Browse files Browse the repository at this point in the history
Remove the `Prototype.js` dependency of the Sound Plugin in favour of
a plain JavaScript XMLHttpRequest().

See also jenkinsci/build-monitor-plugin#159
  • Loading branch information
bascht committed Feb 16, 2017
1 parent b3f1e42 commit a89fa7a
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
<script type="text/javascript" defer="defer">
function _sounds_ajaxJsonFetcherFactory(onSuccess, onFailure) {
return function() {
new Ajax.Request("${request.contextPath}/sounds/getSounds", {
parameters: { version: VERSION },
onSuccess: function(rsp) {
onSuccess(eval('x='+rsp.responseText))
},
onFailure: onFailure
});
var request = new XMLHttpRequest();
request.open("GET", "${request.contextPath}/sounds/getSounds", true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {

This comment has been minimized.

Copy link
@hplatou

hplatou Jan 17, 2018

I had to change this line to the following to make it work:
if (request.status &gt;= 200 &amp;&amp; request.status &lt; 400) {

onSuccess(eval('x=' + request.response));
} else {
onFailure();
}
};
request.onerror = function() { onFailure(); };
request.send();
return request;
}
}

Expand Down

0 comments on commit a89fa7a

Please sign in to comment.