I have built a website with CodeIginer and I want to implement AJAX and JQuery in one of my pages. The problem is that when I load the content, the URL does not change.
Let’s say that I have these URI:
http://www.example.com/controller/function/paramhttp://www.example.com/controller/function/param2
How can I change from the first one to the second one when I click a button?
In HTML5 you can change the URL:
check http://spoiledmilk.com/blog/html5-changing-the-browser-url-without-refreshing-page/
docs: https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history#The_pushState().c2.a0method
UPDATE
An overview of which browser support the new HTML5 history API:
http://caniuse.com/#search=pushState (caniuse.com is worth to bookmark!)
there are already frameworks that do the hard work for you and even gracefully fallback to the common hash-tag solution:
History.js
Backbone.js
Mootools (via Plugin)
dojo toolkit
… just to name a few.
(!!) BE AWARE
One important side-effect when using the
pushState(citation from the Backbone documentation):