Have you read the entire example page? Because I will consider that you didn't, as you have not mentioned it in the OP.
It, more specifically, says the following:
Magic! Almost. You still need to configure your server to look for pjax requests and send back pjax-specific content.
The pjax ajax request sends an X-PJAX header so in this example (and in most cases) we want to return just the content of the page without any layout for any requests with that header.
To me it seems that pjax
is not that easy to use. You need to handle the sending of the X-PJAX
header.
UPDATE: I have tested the following code on your site (with Firefox console), and it is working:
$(document).ready(function() {
$("#pjax-container a").pjax(
{
container: "#pjax-container",
timeout: 5000
}
);
});
Do note the following things:
- I have restructured the code to be more jQuery-compliant, not sure if that was the issue. What is does now is the following:
-
- On the selector
$("#pjax-container a")
, it uses thepjax()
function.
- On the selector
-
- It targets container
#pjax-container
as the target for replacement.
- It targets container
- Also I have added
timeout: 5000
, because I have read thatpjax
initially has a very lowtimeout
setting, so it would not work on slow webservers.
Another side note: I noticed that pjax
also updates the window.location.href
to the new url, decide for yourself if you want this behaviour or not.