S
S
SASHIKUBIVATOR2021-12-07 19:11:46
AJAX
SASHIKUBIVATOR, 2021-12-07 19:11:46

There is a filter for AJAX, how to make it possible to form a url without using all the parameters?

There is this code that is responsible for the portfolio filter on the SEO agency website. Its problem is that it allows you to select parameters only in order, but I need it to be possible to select, for example, country and industry
and the order of the url would not change portfolio/russia/kontekstnaya-reklama, not kontekstnaya-reklama/russia or something like
var more_id = 64;
Site on WordPress, all data is taken from the select-s in the screen.
Now you can enter data from the admin panel there and if there is one parameter, then it looks like
the site / otdelno-goroda / gorod-moskva, but I would like portfolio / moscow or portfolio / russia / moscow (since moscow is subordinated to russia in the admin panel)
61af87af9045f032088156.jpeg

var big_filter = function () {
   	if($('.ajax_portfolio_page_access .container').text() == 'Записей нет!') {
   		$('#true_loadmore').hide();
   	}
      var array_first = [];
      var array_second = [];
      var array_third = [];
      var array_fourth = [];
      var array_fifth = [];
      var array_order = [];

      var array_first_last = '67';
      var array_second_last = '93';
      var array_third_last = '97';
      var array_fourth_last = '100';
      var array_fifth_last = '0';

      var arrayhome = [];
      var myPOSTS = 0;

        $('.new_add_ajax').on('click', '.custom-option', function () {

        	
        	/*
        	var tab_attribs = [];
        $('.backend__class__input__hidden').each(function () {
          tab_attribs.push( $(this).attr("data-hidden") );
      });
      

        	console.log(tab_attribs);
        	*/

        	var data_src = $(this).data('src');

        	more_id = $(this).data('value');

          if( $(this).parent().parent().data('parent') == '1' ) {
          	array_first.push($(this).data('value'));
          }

          if( $(this).parent().parent().data('parent') == '2' ) {
          	array_second.push($(this).data('value'));
          }

          if( $(this).parent().parent().data('parent') == '3' ) {
          	array_third.push($(this).data('value'));
          }

          if( $(this).parent().parent().data('parent') == '4' ) {
          	array_fourth.push($(this).data('value'));
          }

          if( $(this).parent().parent().data('parent') == '5' ) {
          	array_fifth.push($(this).data('value'));
          }
          
          
          if($(this).parent().parent().hasClass('final')) {
          		array_first_last = array_first.pop();
            	array_second_last = '93';
            	array_third_last = '97';
            	array_fourth_last = '100';
            	array_fifth_last = '0';
            	//array_order = [];
            	//array_order = [];
      }
      
      
      /*else if($(this).parent().parent().hasClass('final2')) {
          		array_first_last = array_first.pop();
            	array_second_last = array_second.pop();
            	array_third_last = 97;
            	array_fourth_last = 100;
            	array_fifth_last = 0;
            	//array_order = [];
      }*/
      
      if($(this).data('value') == 64) {
        $(location).attr('href', data_src);
      }
          else {

            if(array_first.length != 0) {
            	array_first_last = array_first.pop();
            }

            if(array_second.length != 0) {
            	array_second_last = array_second.pop();
            }

            if(array_third.length != 0) {
            	array_third_last = array_third.pop();
            }

            if(array_fourth.length != 0) {
            	array_fourth_last = array_fourth.pop();
            }

            if(array_fifth.length != 0) {
            	array_fifth_last = array_fifth.pop();
            }

            if($(this).parent().parent().hasClass('parent')) {
            	array_first_last = 64;

I don’t understand myself whether I singled out the code section correctly, but this one is responsible for Ajax and, as I understand it, due to the fact that 64 is the ID of the first select, it does not work as I want

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dubrovin, 2021-12-08
@alekcena

Understood nothing.
1) Learn to convey the idea to people who do not understand what your task is at all.
2) Learn how to format code.
I will answer the question

There is a filter for AJAX, how to make it possible to form a url without using all the parameters?

To do this, we make it into a function, and use destructuring and a lot of if
function({a,b}){
if(a) url +=
//ajax
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question