开发者

jQuery-pjax vs history.js to load specific content when clicked

I need to ajaxify my site, like loading a spinner or something for rendering sp开发者_高级运维ecific content in a page when clicking a link.

I have found 2 good jQuery plugins.

  • https://github.com/defunkt/jquery-pjax
  • https://github.com/browserstate/history.js

What is their main difference? It seems they are doing the same job. Well, maybe one uses the ajax then returns the html (pjax) and one uses a so-called html5 push state or something.

Is there another way doing this? (simpler or with only jQuery) I think it's too overkill to use either of those plugins (but I'm not sure if there is a simpler way for doing this).


author of History.js here.

  • History.js is extremely low-level and just focuses on providing a cross-browser compatible interface for the HTML5 History API
  • PJAX is high-level and utilises the HTML5 History API to provide a an interface for upgrading your website with AJAX using the two technologies.

So you can get PJAX to use History.js so that it supports cross browsers. There is actually a request about this here.

Though that doesn't mean History.js leaves you on your own either in regards to AJAX, it does provide you with a high-level sample for using History.js with AJAX here and you can find more info about how that was created here. Essentially that gist and PJAX do the same thing, but they have gone about them in different ways.

In regards to simpler, History.js is the most low-level basic shortest simple thing you can get which will ensure the HTML5 History API works in all browsers - that's it's aim, to be as low-level and compact as possible so other things can extend it the way they want - such as PJAX or that Gist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜