zoukankan      html  css  js  c++  java
  • ajax无刷新分页

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css"
              integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
        <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
        </script>
    </head>
    <body>
    <table>
        <tr>
            <td>编号</td>
            <td>房源名称</td>
            <td>图片</td>
        </tr>
        <tbody id="body">
        <tr><td>1</td><td>1123</td><td><img  src="123.jpg"  width="100px"></td></tr>
        </tbody>
    </table>
    <a page="1" class="page">首页</a>
    <a page="1" class="page">1</a>
    <a page="2" class="page">2</a>
    <a page="3" class="page">3</a>
    <a id="last_page" page="" class="page">尾页</a>
    </body>
    </html>
    <script>
        $(function () {
    
        })
        $(".page").click(function(){
            let  page=    $(this).attr('page');
            $.get('http://www.house1.com/index.php/api/getlist',{page:page},function (res) {
                let   data=res.data.data;
                let  html="";
                $(data).each(function(i,item){
                    html+='<tr><td>'+item.id+'</td><td>'+item.fang_name+'</td><td><img  src="'+item.fang_picurl+'"  width="100px"></td></tr>'
                })
                $("#last_page").attr('page',res.data.last_page);
                console.log(html);
                $("#body").html(html);
    
            },'json')
    
        })
        function  getinfo(page) {
            $.get('http://www.house1.com/index.php/api/getlist',{page:page},function (res) {
                let   data=res.data.data;
                let  html="";
                $(data).each(function(i,item){
                    html+='<tr><td>'+item.id+'</td><td>'+item.fang_name+'</td><td><img  src="'+item.fang_picurl+'"  width="100px"></td></tr>'
                })
                $("#last_page").attr('page',res.data.last_page);
                console.log(html);
                $("#body").html(html);
    
            },'json')
    
        }
    
    </script>
  • 相关阅读:
    Mahout推荐算法ItemBased
    ALSA安装编程指南
    windbg更改cmd的token提升其特权
    至尊问题
    什么是“Bash”破绽?
    hdu 1548 A strange lift
    C 循环链表
    C++ 链表
    C_数据结构_链表的链式实现
    C _数据结构 _线性表的顺序存储
  • 原文地址:https://www.cnblogs.com/cyxng/p/14205500.html
Copyright © 2011-2022 走看看