views:

543

answers:

4

hello friends,

I have loaded a page into div using jQuery. But when i refresh the webpage will go to initial stage?

How can i load the same page after refresh?

let the inital stage is

$("div").load("a.htm")

after clicking on a button it will load

$("div").load("b.htm")

now the division contains b.htm and after refreshing it is loading a.htm I need to avoid this if the div contains b.htm after refreshing it should load the b.htm

how can i achive this????

A: 

One possible way to achieve this is to use cookies. Once you load b.htm with AJAX set a client cookie and when you refresh the page check for the presence of this cookie and load the appropriate page.

Darin Dimitrov
A: 

You'll need to keep a note of which page is currently loaded, store it somewhere (local browser storage, or perhaps server-side), and on reloading your page checking against it and re-loading the div's content.

Sychare Jedko
+4  A: 

Hi there friend, you are definitely looking for this one.

Reigel
thankz for the answerbut i find answer given by Leventix is more easy to implement
RSK
Cool!... I'm glad you figured it out... ;) cheers!
Reigel
+4  A: 

Everytime you load a page into a div, you should alter the URL in the location bar to something like: http://example.com/#b.html. This will not navigate away from the current page, but when they reload (or open the saved bookmark), you can check the URL and use the part after # to indentify the page.

Leventix
+1 imo the best approach as this also works when you go back and forth in the browser history.
Felix Kling