4

Does anyone know how to solve the 'Uncaught SyntaxError: Unexpected token <' error? It's on the first line <!DOCTYPE html>, I've even tried deleting that line, but got the same error on <html>.

I've been looking for answers for a while now, and nothing works for me! I know as soon as I post this, I'll get the answer immediately tho.

All the other pages work fine, with no errors and no warnings, all the js/css/whatever files are called in the same file which is shared by all the pages (app.blade.php).

The only 404 errors I'm getting are from the images, but I've tried deleting the img paths and still get the same error. I'm also getting 404 on the images on app.blade.php but those are working fine on the other pages, so I don't think that's it.

The controller was basically copy/paste from another project. I've tried dd($product) and looks fine.

Long story, short: everything looks fine and I'm going crazy. Anyone know what it could be?

Comments
  • 0
    what browser, ie, if so,what version? i would say check other browsers first, cus this sounds like a js error,
    ... possibly ie11 not understanding arrow pointers?🤔
  • 2
    Sound like somewhere you're trying to load a JS file, but your server responds with HTML
  • 0
    @hitko this

    something is trying to parse the 404 html error page while not expecting html
  • 0
    @irene it's just normal html, with some php/blade in it. But I've tried commenting that out and nothing
  • 0
    @BadCompany it's chrome, I don't really know what version I'll check when I get home
  • 0
    @hitko I do only get errors in the js files, but every other page is loading the same files...
  • 0
    I don't understand. Can you elaborate please?

    On which route do you get that uncaught error?

    For image 404, are you sure your images have correct permission?
  • 0
    @cantthinkofone
    If its chrome u should be able to debug fast,most of time the error will point to the exact location of the problem.
    And yes probably all libs are loaded, but wether the page uses a specific function( or whatever) it will run into the error or not, maybe even a specific parameter causes this error to occur, and that can be page-specific
  • 0
    UPDATE: I've been busy latelly, so sorry if I've let you all without a response. And thank you for trying to help.

    I saw someone, on SO, talk about how, when they got this error, it was a route problem, and specificly talked about a 404 route (what he said: 'This happened to because I have a rule setup in my express server to route any 404 back to /#').

    I remembered I had added one, so I decided to delete the route. Now I'm getting 404 errors in every file and every image, it looks like a path problem (for exemple, the path is http://localhost/img/banner.jpg/ but chrome is looking for http://localhost/product/img/...).

    I still don't have time to try and fix this now, so I'll deal with this when I do have the time.
  • 1
    Are you using Laravel's asset() function or storage function to get your images? Or just plain HTML way.

    <img src="img/foo.jpg">

    Or

    <img src="{{ asset('img/foo.jpg') }}">

    @cantthinkofone
  • 1
    @cursee I thought asset() was deprecated in laravel 5.7? I've just been using plain html paths. But I've tried using asset() with one image, and it worked, looks like that was the problem. Thank you!!
  • 1
    @cantthinkofone anything under public can still be accessed by that function. I'm also on 5.7
Add Comment