I have a project in which different pages on a website will load into one wrapper; when clicking on a page link, the content is that page is loaded into the wrapper instead of the user being taken to a new page. The site is being built with PHP and MySQL, and the page is not supposed to reload. Apparently, it's supposed to be one smooth motion.
I've run through a few options that don't quite cut it. I've considered just including all files and having them within divs with no display, so that when a page is selected JavaScript will update the div display to visible. The problem with this is that it forces ALL of the pages of be parsed, which just means superfluous database queries and a resulting slower page load time.
Another thing that I have tried is to start an AJAX call when the page link is clicked. The JavaScript will pass the page name to a PHP script, which will them set a session variable ,$_SESSION['page_name'], equal to the page name passed. Using this, I can then do something like this:
//assume $page is equivalent to $_SESSION['page_name']
if(isset($page) && file_exists("pages/$page")
{
require_once "pages/$page";
}
But this requires the page to be refreshed in order to work. I am trying to get this all done without the page reloading.
So now I'm a bit stuck. Any suggestions?