Can't get basic pjax example to work

EDIT: (non) working example here: http://www.jogos-mmorpg.com/pjax.html

I am trying to reproduce a very simple PJAX example as described in readme ( https://github.com/defunkt/jquery-pjax )

This is index.html:

<!DOCTYPE html>
<html>
    <head>
         <script src="http://pjax.heroku.com/jquery.js"></script>
         <script src="http://pjax.heroku.com/jquery.pjax.js"></script>

        <script type="text/javascript">
            $(document).ready(function(){
                $(document).pjax('a', '#pjax-container')
            });
        </script>

    </head>
    <body>

      <h1>My Site</h1>

      <div class="container" id="pjax-container">
        Go to <a href="./next.html">next page</a>.
      </div>

    </body>
</html>

And this is next.html

<p>next page</p>

When I click on the β€œnext page” link, I just go to next.html, and the only thing I see on the screen is the β€œnext page” paragraph, just like me with pjax completely disabled.

What am I missing?

+4
source share
2 answers

? , , OP.

, , :

! . pjax- pjax- .

pjax ajax X-PJAX, ( ) .

, pjax . X-PJAX.

: ( Firefox), :

$(document).ready(function() {
    $("#pjax-container a").pjax(
        {
            container: "#pjax-container",
            timeout: 5000
        }
    );
});

:

  • , jQuery, , . :
    • $("#pjax-container a") pjax().
    • #pjax-container .
  • timeout: 5000, , pjax timeout, -.

: , pjax window.location.href URL-, , .

+5

:

<script type="text/javascript">
$(document).ready(function(){
$(document).pjax('a', '#pjax-container')
})

:

<script type="text/javascript">
$(document).ready(function(){
$(document).pjax('a', '#pjax-container')
});

-2

All Articles