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.
精彩评论