HTML5 Pushstate Call

时间:2011-10-27 21:55:02

标签: javascript ajax html5

所以我试图在我的JavaScript Ajax函数中调用pushstate方法,但它不代码是:

HttPRequest.onreadystatechange = function() {
if(HttPRequest.readyState == 3)  // Loading Request {
document.getElementById("listarticles").innerHTML = '<img src="images/spiral.gif" align="center" />';}
if(HttPRequest.readyState == 4 && HttPRequest.status == 200) // Return Request {
var response = HttPRequest.responseText;
document.getElementById("pagetitle").innerHTML = 'New Articles';
document.getElementById("listarticles").innerHTML = response;
window.history.pushState(newarticle,'New Articles','newarticles');}
}

ajax响应在屏幕上打印得很好但是pushstate不起作用,因为我的url没有改变。谁知道我的问题是什么?最后,当第一次加载页面时也会调用此函数。

0 个答案:

没有答案