thinkphp5 Ajax搜索分页

Posted Harry-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thinkphp5 Ajax搜索分页相关的知识,希望对你有一定的参考价值。

function sousuo($page){
            var URL=\'\';
            if($page){
                URL=\'__URL__/index/usercenter/selectorder?page=\'+$page;
            }else {
                URL=\'__URL__/index/usercenter/selectorder\';
            }
            var ktime=$("#some_class_1").val();
            var eyime=$("#some_class_2").val();
            var content=$(".content");
            content.remove();
            $(\'.pagecss\').empty();
            $(\'.va-m\').remove();
            $.ajax({
                type: "post",
                data: {ktime:ktime,etime:eyime},
                url: URL,
                dataType: "json",
                success: function (arr) {
                    var html ="";
                    for (var i= 0;i<arr[0][\'data\'].length;i++){
                        html+=\'<tr class="text-c va-m"> \' +
                                \'<td>\'+arr[0][\'data\'][i]["orderId"]+\'</td>\' +
                                \' <td>\'+arr[0][\'data\'][i]["username"]+\'</td>\' +
                                \' <td>\'+arr[0][\'data\'][i]["totalPrice"]+\'</td>\' +
                                \' <td>\'+arr[0][\'data\'][i]["creatTime"]+\'</td>\' +
                                \' <td>\';
                        if(arr[0][\'data\'][i][\'state\']==0){
                            html+=\'待支付\'
                        }else if(arr[0][\'data\'][i][\'state\']==1){
                            html+=\'已完成\'
                        }else if(arr[0][\'data\'][i][\'state\']==2){
                            html+=\'已发货\'
                        }else if(arr[0][\'data\'][i][\'state\']==3){
                            html+=\'待发货\'
                        }else if(arr[0][\'data\'][i][\'state\']==4){
                            html+=\'取消\'
                        }
                        html+=\'</td>\' +
                                \' <td>\'+arr[0][\'data\'][i]["goodsName"]+\'</td>\' +
                                \' <td> \' +
                                \'<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target=".bs-example-modal-lg">再次购买</button>\' +
                                \' <button type="button" class="btn btn-success btn-xs" onclick=\\\'show_order("订单详情","__URL__/index/usercenter/showorder?orderid=\'+arr[0][\'data\'][i][\'orderId\']+\'","1000","1200")\\\'>查看订单</button>\' +
                                \' </td>\' +
                                \' </tr>\';
                    }
                    $(\'.abc\').append(html);
                    $(\'.pagecss\').append(arr[1]);
                    $(\'.pagination>li>a\').attr(\'href\',\'#\');
                    $(\'.pagination>li>a\').each(function(index){
                        $(\'.pagination>li>a\').eq(index).click(function(){
//                            alert($(\'.pagination>li>a\').eq(index).html());
                            if($(\'.pagination>li>a\').eq(index).html()==\'»\'){
                                var a=$(\'.active>span\').html();
                                sousuo(parseInt(a)+1);
                            }else if($(\'.pagination>li>a\').eq(index).html()==\'«\') {
                                var b=$(\'.active>span\').html();
                                sousuo(parseInt(b)-1);
                            }else{
                                sousuo($(\'.pagination>li>a\').eq(index).html());
                            }

                        });

                    })
                }
            });
        }

 

以上是关于thinkphp5 Ajax搜索分页的主要内容,如果未能解决你的问题,请参考以下文章

关键词搜索&分页功能的前端代码(ajax + jQuery)

thinkphp5内置分页功能第二页没有拿到参数,如何解决?

thinkphp5原生查询时,查询结果怎么分页,具体代码应该怎么写?

ThinkPHP5杂技

Jquery 插件,如 dataable,但根据需要具有 ajax 分页和服务器端搜索

带分页的 Ajax 搜索 [Laravel]