问题描述
我要ajaxify我的网站,如点击一个链接时,加载微调或东西的渲染具体内容在页面
I need to ajaxify my site, like loading a spinner or something for rendering specific content in a page when clicking a link.
我已经找到2良好的jQuery插件。
I have found 2 good jQuery plugins.
- https://github.com/defunkt/jquery-pjax
- https://github.com/browserstate/history.js
什么是它们的主要区别?看来他们都在做同样的工作。好吧,也许有使用AJAX然后返回HTML(pjax)和一个用所谓的HTML5推状态什么的。
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.
有另一种方式这样做? (简单或仅jQuery的),我认为这是太大材小用为使用这些插件的(但我不知道是否有这样做的一个简单的方法)。
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).
推荐答案
History.js这里的作者。
author of History.js here.
- History.js是非常低的水平,只是侧重于提供一个跨浏览器兼容的接口,为HTML5历史API
- PJAX是高层次,并利用HTML5历史API提供了一个接口,用于升级您的网站使用AJAX使用这两种技术。
所以,你可以得到PJAX使用History.js,使其支持跨浏览器。其实是有一个关于这个这里请求。
So you can get PJAX to use History.js so that it supports cross browsers. There is actually a request about this here.
虽然这并不意味着History.js让你在你自己无论是在关于AJAX,它为您提供了高层次的样品使用History.js与AJAX的,你可以找到关于如何被创建的详细信息的。本质上是精神和PJAX做同样的事情,但他们已经对他们以不同的方式。
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.
在关于简单,History.js是最低级的基本最短简单的事情,你可以得到,这将确保HTML5的历史API的工作在所有浏览器 - 这是它的目标,是低层次和紧凑越好所以其他的事情可以扩展它,他们想要的方式 - 如PJAX或要点
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.
这篇关于jQuery的-pjax VS history.js到点击时加载的具体内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!