tags:

views:

85

answers:

1

Hi,

I have a website where there is a lengthy list of items to display so I am using Pagination to make the load on server easier.

However, I am doing the pagination via Ajax so when the user clicks on Next Page or Previous Page linkbutton, the data repeater is refreshed with ajax.

This was working fine until, people started to click on the item and then click back, it takes them to the first page.

suppose you scan about 10 pages, by clicking on the "Next Page" button. The data changes, but the URL in the browser doesnt. And you think you found what you want so you click on it, the browser loads different page, and when you click back, the browser takes you to previous page but since the url did not change, you are back to page 1.

Currently, I have removed ajax so the url changes everytime, but I have seen several website re-write the url in browser when ajax even happens, and I was wondering if I could do the same.

Google search for url re-write digs up only seo routing stuff, nothing on what I actually want (i am sure i am not using the right words)

I was interested to know this problem, any clues or leads on this one? thanks!

ps: several questions here were kind of close, but was either too complicated or too deviated. sorry if its a duplicate.

+1  A: 

The only part of an URL that you can change in js, client-side, without forcing browser to reload whole page is an anchor part (http://domain/page#anchor - the part after # sign). This part is used by many js application (e.g. Google Picassa), also by silverlight to provide browser history support. You'd have to set an anchor part when navigating to another page of your data. When the page is loaded, just check the anchor part and load appropriate page. Also, you'd have to periodically check for changes - this will happen when user uses back/forward feature in his/her browser. (There could be an event that is fired when that happens, I just haven't found it)

maciejkow
hi, thanks for the answer, is there any particular name that this is used for this method that i can search on google? changing anchor part is just fine for me, actually, its what I want too. thnanks much.
iamserious
I have found an article on how to do this with jquery: http://asciicasts.com/episodes/175-ajax-history-and-bookmarks Hope that helps, or at least gives you more "keywords" to look for details
maciejkow
whoa! this is exactly what I wanted! thanks a ton. I spent ages trying to search, in vain, for an article like this!
iamserious