pjax demo 使用教程基于tp5 pjax demo

复制代码
<style>
    .spinner {
        width: 150px;
        text-align: center;
        /*display: none;*/
    }

    .spinner > div {
        width: 30px;
        height: 30px;
        background-color: #67CF22;

        border-radius: 100%;
        display: inline-block;
        -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
        animation: bouncedelay 1.4s infinite ease-in-out;
        /* Prevent first frame from flickering when animation starts */
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
    }

    .spinner .bounce1 {
        -webkit-animation-delay: -0.32s;
        animation-delay: -0.32s;
    }

    .spinner .bounce2 {
        -webkit-animation-delay: -0.16s;
        animation-delay: -0.16s;
    }

    @-webkit-keyframes bouncedelay {
        0%, 80%, 100% { -webkit-transform: scale(0.0) }
        40% { -webkit-transform: scale(1.0) }
    }

    @keyframes bouncedelay {
        0%, 80%, 100% {
            transform: scale(0.0);
            -webkit-transform: scale(0.0);
        } 40% {
              transform: scale(1.0);
              -webkit-transform: scale(1.0);
          }
    }
</style>

    <div class="spinner">
        <div class="bounce1"></div>
        <div class="bounce2"></div>
        <div class="bounce3"></div>
    </div>
<script type="text/javascript">
    $(document).on('pjax:send', function() { //pjax链接点击后显示加载动画;
        $(".spinner").css("display", "block");
    });

    $(document).on('pjax:complete', function() { //pjax链接加载完成后隐藏加载动画;
        $(".spinner").css("display", "none");
    });
    $(document).pjax('.pjax,.pagination a,.pjax2', '#container', {fragment:'#container', timeout:8000});
</script>
复制代码

请注意如果使用的是tp5 框架,它默认返回的html结构是json 需要在配置项里面修改为html:

// 默认AJAX 数据返回格式,可选json xml ...  [ todo 这里默认是 json 由于后台采用 pjax 需要接收的是html]
1
'default_ajax_return'    => 'html',

 pjax 引用官方地址

1
<script src="https://pjax.herokuapp.com/jquery.pjax.js"></script>

  

posted @   猖狂的小山猪  阅读(1255)  评论(1编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示