0

Hi guys. I'm still a newbie with ajax and I have a problem that I guess has a standard solution that I don't know.

Here is the situation.
I have my ajax navigation from page to page and I use jQuery and a POST method to send the information to a PHP script. And that works fine. The problem comes when I refresh a page or press the back button on the browser. If I refresh it sends me to my defoult page where I load the PHP scripts and if I press back it goes to the previous website I visited not the previous page I opened in my website.

What is the way to fix the problem. And can you give me some kind of a guide line for Ajax based architectures.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by hielo
0

create cookie (ex: lastPageLoaded), and whenever you make an ajax request, upon successful retrieval of your content, update the cookie to the url you used last.

So, upon page load you just need to see if the cookie exists, If yes, load the page/content from whatever url is in the cookie. If not, then load your default page/content.

If you are using jquery, there's a cookie plugin that is very easy to use:
https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.