开发者

AJAX / History - When is the right time to call the `pushState` method in AJAX app?

I'm working with AJAX and history object (with the .pushState method). I just want to know when is the right time to call pushState method? Is it before request? after request? or on what state of XMLHttpRequest's readyState should I call it? As much as possible, I want it to behave like a normal requ开发者_StackOverflowest (without AJAX).


Only HTTP 200's normally get added to a browsers history. So it probably makes sense to do

readyState == 4 && status == 200

That way if your Ajax call has a 404 error for some reason it won't be added to history just like in normal browsing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜