D
D
Dmitry2021-01-11 12:52:28
1C-Bitrix
Dmitry, 2021-01-11 12:52:28

News filter using RestartBuffer does not work correctly. What could be the reason?

Good afternoon.
This is the first time I've encountered ajax content substitution, I've always done just get parameters in the url.
The problem is this:
1. before calling the news component, I wrote the following:

if ($_GET['_ajax'] == 'y') {
                $GLOBALS['APPLICATION']->RestartBuffer();
}

2. After component:
if ($_GET['_ajax'] == 'y') {
   die();
}


js script:
$('.portfolio--filter a').click(function(){
    $('.portfolio--filter a').removeClass('active-link');
    $(this).addClass('active-link');
    let url = $(this).attr('href')+'?_ajax=y';
    $.ajax({
    url:     url,
    type:     "GET",
    success: function(response) {
      $('#portfolio-wrapper').html(response);
    },
    error: function(jqXHR, textStatus, errorThrown){ 
      console.log('Error: '+ errorThrown);
    }
  });
  return false;
})


The filter itself works, but the problem is that the entire page of the site is inserted into the content area.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smilingcheater, 2021-01-11
@smilingcheater

Try to substitute this flag in the component parameters so that it is taken into account in the cache key
'IS_AJAX' => $_GET['_ajax']
your component has already worked and cached, so the code is not re-executed
Why don't you want the Ajax mode built into Bitrix for components to use?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question