I'm currently designing a system working with steps (like an airline booking, where you pass on various steps to buy a ticket) and these steps are being done via AJAX. So, the index.php file is the sole file loaded and the pages' are being loaded via AJAX on the main div.
The system is working as it should be, but I need to ensure the variables' passing on the subsequent loaded pages, based on the data entered before. E. g.:
I have a form on page 1 where the user enter some data, like his name and country. When clicking submit, the button triggers an AJAX request where the result is the content of page 2, being loaded on the div. But I need that the page 2 have the variables filled with the values on page 1. Page 2 have another form with new data and another submit button. When clicked, it requests via AJAX the page 3 which have to contain the variables at pages 1 and 2. And so on.
Which is the smartest way to do that? Using PHP session? Passing via $.get or $.post?
I request an opinion of you.
Thank you very much.
div, using the data entered and the data processed based on the entrance made on page1. I'm trying to use AJAX to make a more presented and smart page for the user, avoiding to the page to be reloaded every time. The system is working fine using PHP only, where I'm passing the variables using$_POSTon hidden fields. The idea is: also pass the variables to the subsequent pages, to be processed and shown by them, without leaving the mainindexpage.jsonto pass it back to the original ajax call and then populate it on page2 via JQuery.. see yossarian's answer below..