Advertisement
MChaos

filter

Jan 6th, 2022
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. $('body').on('click', '.filter-results-btn', function (e) {
  2.     e.preventDefault();
  3.     var price_from = $('input[name="price_from"]').val();
  4.     var price_to = $('input[name="price_to"]').val();
  5.     var page = $('#page').val();
  6.     var sort = $('#sort').val();
  7.     sort = '&sort='+sort
  8.     var lang = $('#lang_site').val();
  9.     var full_url_page = $('#full_url_page').val();
  10.     var category_id = $('#category_id').val();
  11.     var url ='/'+ lang + '/filter_products/';
  12.     page = '&page='+page;
  13.     var filter = $('.filter__input:checked').serialize();
  14.     var price = '&price_from='+price_from+'&price_to='+price_to;
  15.     filter = filter + price + page + sort;
  16.     history.pushState({}, ' ', '?'+filter);
  17.     $.ajax({
  18.         url: url, // путь к обработчику
  19.         type: 'POST', // метод отправки
  20.         dataType: 'html',
  21.         data: {filter:filter,category_id:category_id,full_url_page:full_url_page},
  22.         success: function (data) {
  23.             $('.all-products-list').html(data);
  24.         },
  25.         error: function (data) {
  26.             console.log(data); // выводим ошибку в консоль
  27.         }
  28.     });
  29.     return false;
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement