Skip to content

Commit 1312193

Browse files
committed
Use fetch API
1 parent f649007 commit 1312193

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

spec/_static/javascripts/version_dropdown.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
function assign_href( a, url, path ) {
2-
var http = new XMLHttpRequest();
3-
http.open('GET', url + "/" + path );
4-
http.onreadystatechange = function() {
5-
if (this.readyState == this.DONE) {
6-
if(this.status != 404 ){
7-
console.log('%%%%', this);
8-
a.href = url + "/" + path;
9-
}
10-
else {
11-
a.href = url;
12-
}
2+
const r = fetch( url + "/" + path );
3+
r.then( response => {
4+
console.log('...', response);
5+
if( response.ok ){
6+
a.href = url + "/" + path;
137
}
14-
};
15-
http.send();
8+
else {
9+
a.href = url;
10+
}
11+
});
1612
}
1713

1814
function add_version_dropdown(json_loc, target_loc, text) {

0 commit comments

Comments
 (0)