duanbamo0127 2014-10-27 22:36
浏览 92

为什么jquery-pjax会删除最外面的标签?

I'm a newbie to jquery-pjax. Now, I'm developing a flexible(no refresh and load content asynchronously) single web page using PHP and jQuery. But some issues occur in my page when using jquery-pjax. One of the issues is that jquery-pjax will strip an outermost tag automatically in asynchronous responses.

Let me see my source code.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="jquery.min.js"></script>
        <script src="jquery.pjax.min.js"></script>
        <script>
            $(document).pjax('#pjax-container a', '#pjax-container', {
                timeout: 1300,
                replace: true,
                fragment: 'body'
            });
        </script>
    </head>
    <body>
        <?php
        if (!isset($_SERVER['HTTP_X_PJAX']))
        {
        ?>
        <h1>A jquery-pjax test page.</h1>
        <div id="pjax-container">
            <?php
            }
            ?>
            <a href=".">Refresh</a>
        <?php
        if (!isset($_SERVER['HTTP_X_PJAX']))
        {
        ?>
        </div>
        <?php
        }
        ?>
    </body>
</html>

In terms only the source code, It seems that there isn't any issue. But when run it and click the refresh link, the link be removed and there is only its caption. I saw a network monitor in my browser, There is the link in the new asynchronous response. (body : <body><a href=".">Refresh</a></body>) But I saw a elements monitor, There isn't the link... (body : <div id="pjax-container">Refresh</div>)

Question : Why jquery-pjax does strip an outhermost tag?

Thanks.

  • 写回答

1条回答 默认 最新

  • dongwo8827523 2014-12-03 13:44
    关注

    I can't reproduce your issue. I set up two pages like your script would spit out

    And when you run it http://jsbin.com/potuputaha/2, pressing the link will replace the page with the <a href="#">Refresh me</a> from the second page.

    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名