X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3fbc8a3d3224a4f5bb4a222aa820d885944a60fe..5ca24de0d04bef18353d3f0ecdd069d0bca34ce2:/app/assets/javascripts/index/query.js 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(); $("