The World’s Largest Online Community for Developers

'; php - HTML shown in browser when using back button - LavOzs.Com

This is kind of weird. I upgraded a Laravel 5.8 application to version 6.x. On an Apache web server with PHP7.3 when I use the browser back button, the plain HTML code is shown in the browser. If I reload the page it all is OK.

On the exact same server I am also running the 5.8 version, and there the back button works fine. Therefor my best guess is that this is an issue with Laravel 6.x

But I cannot find any article about this, so hopefully some one on here can help me out.

In Chrome no error message, just the plain HTML code in view. But in Firefox, I am getting this error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Well I have figured it out... When there is a jQuery Ajax call on a page that does a POST or a GET to it's own and data type is set to json, the page's header changes to application/json. It's weird that this was not an issue in Laravel 5.8, but it is all of a sudden in version 6.x

    url: '/page',
    headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
    dataType: 'json',
    formData: { media_folder_id: $("#media-folder-id").val() },
    context: $("#fileupload")[0]
When to use self over $this?
How do you parse and process HTML/XML in PHP?
Woocommerce - checkout error after plugin update
laravel form empty when pressing browser back button in Chrome
Random javascript runtime errors on Laravel + Vue
Datatables: Browser freezes after ajax has been load
Display HTML code when clicked back button in Chrome browser?