From 6ad3f433b7fe964c75a1ab800f9843a98457fc50 Mon Sep 17 00:00:00 2001 From: eXeCUT notebook Date: Wed, 23 Jun 2021 07:15:54 +0300 Subject: [PATCH] #859 Added remove existed params before Ajax request --- shop/static/shop/js/catalog.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shop/static/shop/js/catalog.js b/shop/static/shop/js/catalog.js index 1284fb876..2fd608d3f 100644 --- a/shop/static/shop/js/catalog.js +++ b/shop/static/shop/js/catalog.js @@ -124,6 +124,8 @@ djangoShopModule.controller('CatalogListController', ['$log', '$scope', '$http', this.loadProducts = function(config) { if ($scope.isLoading || fetchURL === null) return; + + config = this.deleteExistedSearchParams(config); $scope.isLoading = true; $http.get(fetchURL, config).then(function(response) { fetchURL = response.data.next; @@ -136,6 +138,17 @@ djangoShopModule.controller('CatalogListController', ['$log', '$scope', '$http', }); }; + this.deleteExistedSearchParams = function (config) { + if (typeof URLSearchParams !== 'undefined') { + let searchParams = new URLSearchParams(fetchURL.substring(fetchURL.indexOf('?'))); + for (let key in config.params) { + if (searchParams.has(key)) { + delete config.params[key]; + } + } + } + }; + this.resetProductsList = function() { fetchURL = djangoShop.getLocationPath(); $scope.catalog.products = [];