Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is pjax working?

Tags:

I just discovered pjax and I find it completly awesome. If I understand it correctly, it's AJAX, but without its problems (fully degradable, the URL and the title of the page is changing when using it, compatible with search bots...).

But I am very curious as how it's working ? How can we change the URL in the browser, without the page to change... I read somewhere you need Firefox 4, is that a new "web" feature then ?

like image 778
Matthieu Napoli Avatar asked Apr 10 '11 14:04

Matthieu Napoli


1 Answers

It's just a wrapper around "$.ajax()". It uses the new "pushState" and "replaceState" methods to manipulate the history.

Also see this SO question too, and notably the link to History.js.

edit — note that by writing "just a wrapper" I do not mean to belittle the pjax plugin. I simply meant that it's not some radical new functionality; it's still XMLHttpRequest under the covers.

like image 57
Pointy Avatar answered Oct 05 '22 08:10

Pointy