Reputation: 1666
I have the following problem: I have two pages. In the first page is a button. When the button is clicked, an ajax request is made to a page that saves data to the session. Then, it redirects me to the second page in which I display this saved data. The problem is that when I go to the second page the data is not displayed, but when I refresh the page the data is displayed. How can I redirect to the second page with the session data stored?
Example:
Before Refresh:
After:
Does anyone have any ideas?
Upvotes: 0
Views: 366
Reputation: 7207
Try this, hope it'll work if you are using jQuery then fine, use e.preventDefault(); and redirect your next page after getting the ajax response.
Upvotes: 0
Reputation: 8411
You should wait for the response of the AJAX request before you forward to the next page.
Preferable use the callback method to redirect to the next page.
If you post some code may be it will be easier to point out.
Upvotes: 3