Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在jquery中使用ajax调用进行过滤和分页_Javascript_Php_Jquery_Ajax_Pagination - Fatal编程技术网

Javascript 在jquery中使用ajax调用进行过滤和分页

Javascript 在jquery中使用ajax调用进行过滤和分页,javascript,php,jquery,ajax,pagination,Javascript,Php,Jquery,Ajax,Pagination,我想在一个脚本中进行过滤和分页。我已经分别完成了过滤和分页。但是,当我结合这两个代码段时,分页不起作用。这里我给出了我已经完成的代码 function getusedcarFilterOptions(){ var opts = []; $checkboxes.each(function(){ if(this.checked){ opts.push(this.name); } }); return opts; }

我想在一个脚本中进行过滤和分页。我已经分别完成了过滤和分页。但是,当我结合这两个代码段时,分页不起作用。这里我给出了我已经完成的代码

 function getusedcarFilterOptions(){
    var opts = [];
    $checkboxes.each(function(){
      if(this.checked){
        opts.push(this.name);
      }
    });

    return opts;
 }

  function updateusedcar(opts){
    $.ajax({
      type: "POST",
      url: "filter.php",
      dataType : 'json',
      cache: false,
      data: {filterOpts: opts},
      success: function(data){

          $('#usedcar1').html(makeTable(data));
          displayRecords();
      }
    });
  }

  var $checkboxes = $("input:checkbox");
  $checkboxes.on("change", function(){
    var opts = getusedcarFilterOptions();
    updateusedcar(opts);
  });

  updateusedcar();




      // fetching records
                        function displayRecords(numRecords, pageNum) {
                            $.ajax({
                                type: "GET",
                                url: "getrecords.php",
                                data: "show=" + numRecords + "&pagenum=" + pageNum,
                                cache: false,
                                beforeSend: function() {
                                    $('.loader').html('<img src="loader.gif" alt="" width="24" height="24" style="padding-left: 400px; margin-top:10px;" >');
                                },
                                success: function(html) {
                                    $("#usedcar1").html(makeTable(data));
                                    $('.loader').html('');
                                }
                            });
                        }

    // used when user change row limit
                        function changeDisplayRowCount(numRecords) {
                            displayRecords(numRecords, 1);
                        }

                        $(document).ready(function() {
                            displayRecords(10, 1);
                        });
    </script>  
函数getusedcarFilterOptions(){ var opts=[]; $复选框。每个(函数(){ 如果(选中此项){ opts.push(这个名称); } }); 返回选项; } 功能更新SEDCAR(opts){ $.ajax({ 类型:“POST”, url:“filter.php”, 数据类型:“json”, cache:false, 数据:{filterOpts:opts}, 成功:功能(数据){ $('#usedcar1').html(makeTable(数据)); 显示记录(); } }); } var$复选框=$(“输入:复选框”); $checkbox.on(“更改”,函数(){ var opts=getusedcarFilterOptions(); 更新SEDCAR(opts); }); updateusedcar(); //获取记录 函数显示记录(numRecords、pageNum){ $.ajax({ 键入:“获取”, url:“getrecords.php”, 数据:“show=“+numRecords+”&pagenum=“+pagenum, cache:false, beforeSend:function(){ $('.loader').html(''); }, 成功:函数(html){ $(“#usedcar1”).html(makeTable(data)); $('.loader').html(''); } }); } //用户更改行限制时使用 函数changeDisplayRowCount(numRecords){ 显示记录(numRecords,1); } $(文档).ready(函数(){ 显示记录(10,1); });
提前谢谢

您应该组合服务器端的代码,否则筛选的记录不会分页,反之亦然。否则,您需要在客户端进行分页,但我认为这将消除分页的主要原因