I have an application which allows the user to switch between 8 different form pages without losing their data. When the user has filled in some information they click a link which calls an ajax function to update the information in the database.
It is all working fine apart from one little glitch.
When a user goes to page 1 to add a new record there is no session variable for the current record. As soon as they move to another page the script that is called through ajax inserts the information into the database gets the auto incremented id and sets the session variable to this, which is then referenced throughout the rest of the pages.
If the user moves onto another page, e.g. page 2 it checks to see if a session variable is set for the current record being worked on and if not it re-directs the user to the home page.
I think what is happening is that the user arrives at page 2 before the ajax script for page 1 has finished processing and as such the session variable is not set in time. All the information has been put into the database but the re-direct still happens back to the home page.
I have tried adding sleep to the beginning of page 2 but that hasn't helped to give it enough time to have the session variable set but that didn’t work.
I have also tried running a quick query just to get the auto incremented id but that also hasn’t solved it.
Does anyone else have any suggestions on how to overcome this problem?
Thanks for any help.