我正在尝试自学如何使用 HTML5 hisory api 和 jquery 创建 Web 应用程序。我正在将页面的内容加载到 div 中,但是当我尝试后退或前进时,什么也没有发生。下面是代码
$(document).on('click',".ul_links",function(e){
loader_img();
var teamid = $(this).attr('id');
var href = '/Myapp/Pages/FundingSourceView.php?teamid='+teamid;
$('#midpanel').load(href,function(response,status,xhr){
if(status=='error')
{
alert('An error occured. Contact admin. Specific error is '+ xhr.status + " " + xhr.statusText);
}
});
var currentState = history.state;
History.pushState(currentState,'',href);
e.preventDefault();
return false
});
我正在使用 History.js 插件,但在实现此功能时遇到了一些困难。
如果变量 href 不是绝对的,我会收到 404 错误。当 href 为绝对时,链接有效,但我不能使用前进或后退按钮来加载以前的内容所有帮助都非常感谢。