回复内容: 求用过的人来回答 教会必定报酬
window.history.pushstate(state, title, url);// https://developer.mozilla.org/zh-cn/docs/web/api/history/pushstate// @状态对象: 记录历史记录点的额外对象,可以为空.// @页面标题: 目前所有浏览器都不支持.// @可选的url: 浏览器不会检查url是否存在,只改变url.url必须同域,不能跨域.
pjax其实就是html5 window.history.pushstate(state, title, url)这个新的api加上传统的ajax技术,一般用来实现无刷新的页面加载.pushstate的作用主要是:改变url和添加返回历史.这样ajax无刷新加载页面后,用户还可以正常进行后退和前进,js的window.history.back()和window.history.forward()也能正常工作.下面就是一个用pushstate + jquery ajax实现的无刷新的页面加载,不支持的浏览器则自动退化成打开原始的链接打开形式.
index.php:index data.php
data.php:datadata content
注意,js统计代码应该放到main块里面才能正常统计页面访问数.