Change a page without refreshing - Laravel / Ajax
<p>I've been searching around for a while not to get the answer to my question but without any luck.</p>

<p>I'm effectively trying to replicate the navigation structure of Soundcloud the way you can click on a link and it'll redirect the page without refreshing using Ajax/jQuery but won't duplicate content and if the user refreshes, the page is still there looking normal.</p>

<p>The issue I have is, I have a master template which is extended on all the views so when I make a call to pull through the page, it'll replicate the page within the div I'm pushing it too. This is resulting in two headers/sidebars etc pulling from the master template.</p>

<p>Another thing which I'm also trying to get this to work for is that, if I remove the master template from the view, it won't show content - but say it did, it wouldn't have styling so if I was to go to directly to that page, it'll load up without styling etc.</p>

<p>This is the working jQuery that pulls through the page properly:</p>

<p><strong>jQ</strong></p>

<pre><code>$(".main-nav li a").click(function(e) {
    e.preventDefault();
    var href = $(this).attr("href");
    $(".content-container").load(href);
});
</code></pre>

<p>I hope this makes sense, if any more information is needed I'll try my best to provide it!</p>

<p>Thanks a million!</p>

<p>Matt</p>

<p><strong>EDIT--</strong></p>

<p>This is still active. I've done a little more digging around and thought of a another way people may be able to shed some more light to. If I wrap the extended master template on views with something like:</p>

<pre><code>if(!$request-&gt;ajax())
@extends('master')
@endif
</code></pre>

<p>That would then only show the master template on that view if the page is being requested via ajax, right? I'm not sure if that's the correct way to go about it but it's worth a try. </p>

<p>As usual, any help is greatly appreciated!</p>