X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/62613e7b479ce351daec94798f1a63b8946d979c..3bdbc35bbd8f44bab813adb5c9afe505868e4a09:/app/assets/javascripts/index/query.js?ds=sidebyside diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 54d5e080f..3673da5db 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -157,16 +157,17 @@ OSM.Query = function (map) { $section.data("ajax").abort(); } - $section.data("ajax", $.ajax({ - url: url, + $section.data("ajax", new AbortController()); + fetch(url, { method: "POST", - data: { + body: new URLSearchParams({ data: "[timeout:10][out:json];" + query - }, - xhrFields: { - withCredentials: credentials - }, - success: function (results) { + }), + credentials: credentials ? "include" : "same-origin", + signal: $section.data("ajax").signal + }) + .then(response => response.json()) + .then(function (results) { var elements; $section.find(".loader").hide(); @@ -221,16 +222,17 @@ OSM.Query = function (map) { .text(I18n.t("javascripts.query.nothing_found")) .appendTo($ul); } - }, - error: function (xhr, status, error) { + }) + .catch(function (error) { + if (error.name === "AbortError") return; + $section.find(".loader").hide(); $("