weixin_33716941 2013-10-23 19:25 采纳率: 0%
浏览 20

Ajax分页不起作用

Here is my code i need to help with pagination

Index.php

 setInterval(function() {
         $(document).ready(function() {

                            $.ajax({//create an ajax request to load_page.php
                                type: "GET",
                                url: "products_ajax.php",
                                dataType: "html", //expect html to be returned                
                                success: function(response) {
                                    $("#responsecontainer").html(response);
                                    //alert(response);

product_ajax.php

  <?php
                $per_page = 4;
                $page = 1;
                if (isset($_GET['page'])) {
                    $page = intval($_GET['page']);
                    if ($page < 1)
                        $page = 1;
                }

                $start_from = ($page - 1) * $per_page;   

                $result = mysqli_query($con, "SELECT * FROM gems WHERE end = 1 LIMIT $start_from, $per_page");
                ?>              
<?php

                    while ($row = mysqli_fetch_array($result)) {

                                <td><?php echo $row['name']; ?></td>
                                <td><?php echo $row['description']; ?> </td>

                    ?> 

paginate starts here with link

 <?php
                $total_rows = mysqli_query($con, "SELECT COUNT(*) FROM gems");
                $total_rows = mysqli_fetch_row($total_rows);
                $total_rows = $total_rows[0];

                $total_pages = $total_rows / $per_page;
                $total_pages = ceil($total_pages); # 19/5 = 3.8 ~=~ 4

                for ($i = 1; $i <= $total_pages; ++$i) {
                    echo "<a href='products_ajax.php?page=$i'>$i</a> &nbsp;&nbsp;";
                }
                mysqli_close($con);
                ?>

how do i create paging work with this code? when i click this its going to products_ajax page

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题