lundi 20 avril 2020

Keep checkbox checked after reload or refresh page

I want make a filtering products on my page with ajax, jquery and php.

I make the pagination with ajax and work very good but I don't know how make a filters.

  1. How keep checkbox checked after reload or refresh page.

In js I have this code

$(document).ready(function(){

load_data(1);

function load_data(page, query = '', qry_stoc = '')
{
  $.ajax({
    url:"ajax/fetch.php?cat=52",
    method:"POST",
    data:{page:page, query:query, qry_stoc: qry_stoc},
    success:function(data)
    {
      $('#dynamic_content').html(data);
    }
  });
}

var stoc = $('.qry_stoc').val();

$(document).on('click', '.page-link', function(){
  var page = $(this).data('page_number');
  var query = $('#search_box').val();
  var stoc = $('.qry_stoc').val();

  load_data(page, query, stoc);
});

$('#search_box').keyup(function(){
  var query = $('#search_box').val();
  load_data(1, query);
});

$('.qry_stoc').on('change', function() {
  var data = $('.qry_stoc').serializeArray();

  var stoc = $('.qry_stoc').val();
  load_data(1, stoc);
});

});




Aucun commentaire:

Enregistrer un commentaire