Question

So I am creating just a fairly normal content based website that is going to load new pages/content in via AJAX for a smoother user experience and some simple transitions. I see a ton of people using a hashbang for similar implementations.

My question is why not just use regular URLs and have server-side determine if the regular page should be served or JSON/XML/etc based on the XMLHttpRequest var? At my first glance here it seems to make more sense to have one URL and I am curious why I see no mentions of this idea/approach in my initial searchings. Perhaps I am just missing something...

ANSWER: I missed that updating a full URL without a page load was not possible before HTML5 history. That is where my confusion arose.

Was it helpful?

Solution

If you only have 1 url, users can't bookmark anything on your site. So you need to do something.

So you can either use hashbangs (aka anchors), or, if you are targeting reasonably new browsers, html5 history.

You can't use regular urls because when you change a url, the entire page reloads.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top