1 year ago

Why is my page content different when I return to it by clicking the back button on my browser?

Posted 1 year ago by Justs

I'm creating a web page with laravel and the main menu pages contents are loaded with ajax. The problem is when I go back to the previous page with the back button of the browser, the browser loads not only the content received by the ajax call but the entire page with additional header and footer.

This is my code:

base.blade.php: // header

// list of menu ...


// footer ...

// some page from menu page.blade.php: @extends('base')


My page content. @stop

// user clicks on the menu link and calls this script script.js: $(".menu_list").on("click", "a.menu_page", function(e) { // get some variables $.ajax({ type: "GET", url: url, dataType: "html", success: function (result) { $("div.main").html(result); } ...

controller.php: ... if(Request::ajax()) return view('page')->renderSections()['main']; } // returned only content of main section

So I don't understand why the browser loads the entire page into the @yield section after returning to the previous page, although the controller only returned part of the page content.

Please sign in or create an account to participate in this conversation.