skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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

    $.ajax({
        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]
    })
    

  2. check for any link tag in the head section of your tag and remove any

    <link type="text/css" rel="stylesheet" href="#" id="example"/>

    with href="#"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search