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 request (without AJAX).
Asked
Active
Viewed 204 times
3

kazinix
- 28,987
- 33
- 107
- 157
1 Answers
1
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.

Paul
- 139,544
- 27
- 275
- 264