php - CI中的ajax jquery分页错误

标签 php jquery ajax codeigniter pagination

在 codeigniter 中的 jquery 分页中出现错误。

    if per_page=5;
    total number 6 and total page 2

    but the pagination like below

    Showing 6 to 6 of 6 |  < 1 2
    But only 5 is shown and last one show in 2nd page.

嗨, friend 们,我陷入了这个错误。这显示在每个页面中。请给我一个解决方案来获得正确的分页

下面的代码正在使用:

            $config['base_url'] = site_url('settings/view_leave_reason_ajax/');
        $config['total_rows'] = $this->leav->getLvReasonCount();
        $config['per_page'] = 5;        
        $config['anchor_class'] = 'ajax_links';
        $config['show_count'] = true;
        $config['div'] = '#list_view';
        $this->jquery_pagination->initialize($config);
        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $data["links"] = $this->jquery_pagination->create_links();
        $data['page'] = $page;
        $data['result'] = $this->leav->getLvReason($config["per_page"], $page);

关于下面 ci 分页的问题:

https://github.com/neotohin/CodeIgniter-Ajax-pagination-Library

查看页面:

<?php if($result=="")
                {?>
                <tr style="height: 50px; background:#ffffff; font-weight: bold;">
                    <td colspan="5" style="width:50px;">
                        No Details Exist
                    </td>
                </tr>
                <?php
                }
                if($result!="")
                {
                $c = $page+1;
                $col1[1]="";
                $col1[2]="#d6e3f6";
                $col=$col1[2];
                    foreach ($result as $row)
                    {
                        $did = $row['id'];
                ?>
                <tr style="height: 50px;background:<?php echo $col;?>;">
                    <td><input type="checkbox" name="c1[]"  value="<?php echo $did;?>" /></td>
                    <td><?php echo $c;?></td>
                    <td><?php echo $row['department_name'];?></td>
                    <td>

                            <a class="fancybox fancybox.iframe" href="<?php echo site_url()."/settings/department_edit/".$this->hrm->encData($row['id']); ?>" ><img class="aicon" src="<?php echo base_url().'/assets/images/edit.png';?>" width="20" title="edit" style="margin-top:4px; margin-left:3px;"></a>
                    </td>   
                </tr>
                <?php  $c=$c+1;
                if($col == $col1[1])    $col = $col1[2];
                else $col = $col1[1];
                    }

                ?>
                <tr style="height: 50px; background:#ffffff; font-weight: bold;">
                    <td colspan="5" style="width:50px;">
                        <input type="button" value="Delete" class="btn_black" onclick="return chkdel()">
                    </td>
                </tr>
                <?php }?>

                <tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?php echo $links; ?></td></tr>

最佳答案

你已经定义了

 $config['div'] = '#list_view';

在您的配置中,但您尚未在 View 中定义该容器。因此不会发送任何 ajax 调用。

所以不是这个

<tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?php echo $links; ?></td></tr>

尝试将容器 <div id="list_view"><?php echo $links; ?></div>如下:

<tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><div id="list_view"><?php echo $links; ?></div></td></tr>

也在分页库中Jquery_pagination.php

line number 184 更改此行来自

if( ( $curr_offset + $this->per_page ) < ( $this->total_rows -1 ) )

if( ( $curr_offset + $this->per_page ) <= ( $this->total_rows -1 ) )

它会工作...

关于php - CI中的ajax jquery分页错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20517843/

相关文章:

javascript - 在每个数组绘图后更新图表,Highcharts

php - preg_replace 将匹配计数传递给第二个参数

javascript - 使用 "this"在表之间移动数据

javascript - jquery改变函数内部的全局变量

jQuery 查询选择器 : is there benefit to selecting by class AND id?

javascript - 如何从客户端脚本使用远程 Web 服务?

php - 从数据库中获取更多数据

php - 使用 AJAX 设置 Flash 数据 session

php - 一个变量的多个比较运算符?

apache2 和 php5-fpm,如何正确处理 *.phps 文件?