- $.ajax({
- url: url,
- type: method,
- oauth: true,
- data: data,
- success: function () {
- OSM.loadSidebarContent(window.location.pathname, page.load);
- },
- error: function (xhr) {
+ fetch(url, {
+ method: method,
+ headers: { ...OSM.oauth },
+ body: data
+ })
+ .then(response => {
+ if (response.ok) return response;
+ return response.text().then(text => {
+ throw new Error(text);
+ });
+ })
+ .then(() => {
+ OSM.loadSidebarContent(location.pathname, page.load);
+ })
+ .catch(error => {