You have to build the proper click link to return. Don't use back button.
Jun 4, 2019
6
Level 1
Issue with browser buttons and AJax pagination
I am bringing back a set of results of Blog posts which are paginated and the pagination is controlled using AJAX to swap the pages. The problem i have is that when i click on a blog post and then click the browsers back button to return to the list of blog post results and the page i was looking at it returns to 'Page 1'. How do i rectify this issue to return to the page i was looking at before i entered the single blog post rather than it resetting to page 1....
here is my code:
JS:
$('.container').on('click', '.pagination a', function(zmm) {
zmm.preventDefault();
var page = $(this).attr('href').split('page=')[1];
var sortby = $('#SortBy').val();
$.ajax({
url: '/searchsort?page='+page,
data: {SortbyList: sortby, name : name, city :city, country :country, category :category, sl:sl},
success: function(data){
$('.search-results-holder').html(data).load();
$('html,body').animate({
scrollTop: $(".profile").offset().top -100
});
}
})
});
Please or to participate in this conversation.