I'm working on a little website endeavor and am trying to use jQuery + ajax to dynamically load in information. As of right now I have a home page ~/home and a profile page ~/profile. These two pages share the same header and footer and I load first the header, then the page, then the footer. When I switch pages I just replace the page div with another's html. However the problem here is if you navigate to ~/profile and load it just loads an html page with the page div content.
Basically I'm wondering if anyone has good suggestions on a system to be able to navigate to any link and have the browser know to load the separate header and footer files without hardcoding all of it into each file. I assume it would involve some sort of PHP / framework, but the only one I've worked with CodeIgniter which I am very unexperienced with.
This snippet from here looked promising: CodeIgniter + jQuery(ajax) + HTML5 pushstate: How can I make a clean navigation with real URLs?
if (!$this->input->is_ajax_request())
$this->load->view('header');
$this->load->view('your_view', $data);
if (!$this->input->is_ajax_request())
$this->load->view('footer');
My only question would be how to have a controller set up that intercepts any link on my domain and loads in the header and footer, with the header file having the linked js file that knows which page to load into the middle via ajax.