From: Tom Hughes Date: Sun, 12 Mar 2023 17:52:39 +0000 (+0000) Subject: Fix "load more" button on search results X-Git-Tag: live~1389 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/35c59bff0d8027411925d46203c608dbd742258e Fix "load more" button on search results Fixes #3969 --- diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index b7bca1d2a..1c1da3677 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -62,13 +62,23 @@ OSM.Search = function (map) { e.preventDefault(); e.stopPropagation(); - var div = $(this).parents(".search_more"); + var div = $(this).parents(".search_more"), + csrf_param = $("meta[name=csrf-param]").attr("content"), + csrf_token = $("meta[name=csrf-token]").attr("content"), + params = {}; $(this).hide(); div.find(".loader").show(); - $.get($(this).attr("href"), function (data) { - div.replaceWith(data); + params[csrf_param] = csrf_token; + + $.ajax({ + url: $(this).attr("href"), + method: "POST", + data: params, + success: function (data) { + div.replaceWith(data); + } }); } diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index fc8b3a60b..b779d353e 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -98,7 +98,7 @@ class GeocoderController < ApplicationController # create parameter hash for "more results" link @more_params = params - .permit(:query, :minlon, :minlat, :maxlon, :maxlat, :exclude) + .permit(:query, :minlon, :minlat, :maxlon, :maxlat, :exclude, :xhr) .merge(:exclude => more_url_params["exclude_place_ids"].first) # parse the response