小编mil*_*les的帖子

pjax不起作用

我在使用pjax时遇到了麻烦.

我在https://github.com/defunkt/jquery-pjax下载了最新的pjax

然后我编写代码作为演示,但它不起作用.main.html

<!DOCTYPE html>
<html>
<head>
    <title>main.html</title>
    <script type="text/javascript" src="../js/jquery/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="../js/jquery/plugin/jquery.pjax.js"></script>
    <script>
        $(function(){
            $(window.document).pjax('a', '#pjax-container')
        });
    </script>
</head>
<body>
    <h1>My Site</h1>
    <div class="container" id="pjax-container">
        Go to <a href="MyHtml.html">next page</a>.
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

和MyHtml.html如下

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>MyHtml.html</title>
  </head>
  <body>
    This is my HTML page. <br>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我点击链接时,它直接转发到MyHtml.html.我的代码有什么问题吗?

我可以确定pjax有效,当我点击main.html的后退按钮时,它回到我在main.html之前使用的另一个页面.

jquery pjax history.js

0
推荐指数
1
解决办法
2523
查看次数

标签 统计

history.js ×1

jquery ×1

pjax ×1