Krueger Krueger - 1 year ago 149
Ajax Question

Which one is better pushstate or location.hash?

vs HTML5
. Which one of these would be better to meet the url with the ajax request and why?

Answer Source

location.hash has a better support than the history.pushState method.
The advantage of the pushState method is that you can bind a state to the history entry.
If you don't need this state object, I recommend to use the location.hash property, to have a better compatibility with older browsers.

location.hash = 'new-hash';
console.log(history.state); // null or undefined

history.pushState({extraData: "some state info"}, '', 'new-hash'); //<---
console.log(history.state); // [object Object] = {"extraData": "some state info"}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download