Hey everyone, I'm working on an app in Codeignitor that updates content based on three select tags. The first tag is for selecting a city, which then populates the locality select tag for that city and makes the category select tag visible. I've set up multiple ajax calls to ensure the content is updated correctly. However, I encountered an issue when going back using the browser's back button - the select tags get messed up.
I realized that I needed a session variable so that when users go back using the browser, they stay at the same select tag stage. I managed to store the session with the selected city successfully. To check if everything was working fine, I used:
$(document).ready(function () {
$city="<?php echo $this->session->userdata('city'); ?>";
alert($city);
});
Now here's the problem: whenever I go back after selecting Los Angeles (LA), the alert box shows up blank until I refresh the page. Similarly, after selecting LA and then London, the alert box displays 1 and 2 respectively only after refreshing the page.
I did some research and found out that the refreshed session is only available on the next server request. This poses a challenge for me as I want the refreshed info to keep my users at the same stage they left off. You can read more about this issue here.
Do you have any suggestions on how I can solve this problem?