I am creating a web app in php. i am loading content through a ajax based request.
when i click on a hyperlink, the corresponding page gets fetched through ajax and the content is replaced by the fetched page.
now the issue is, i need a physical href so that i can implement facebook like functionality and also maintain the browser history property. i cannot do a old school POSTBACK to the php page as I am doing a transition animation in which the current page slides away and the new page slides in.
Is there a way I can keep the animation and still have a valid physical href and history.
the design of the application is such:
- the app grabs an rss feed.
- it creates the DOM for those rss feeds.
- upon clicking on any headline, the page animates and takes to the full story of the rss feed.
- i need to create “like” button on the full story page. but i dont have a valid url.
Firstly, if you need a URL for facebook then think up a structure that gives you one, such that your server-side code will load the correct page when given that URL. This could be something like
http://yourdomain.com/page.php?feed=<feedname>&link=<linknumber>, which would allow you to check the parameters using the PHP$_GETarray. If you don’t have the parameters then load the index page; if you do then load the relevant article.Secondly, use something like history.js to give you cross-browser support for the HTML5
pushState()functionality so that you can set the page URL when you do the AJAX call, without requiring the browser to do a full reload.