Syntaxerror Error: Unexpected token < in Chrome

Asked

Viewed 1,226 times

0

I’m having trouble with this code... is saying " Syntaxerror: Unexpected token < " on the Google Chrome console. But I don’t see any "," or ";" out of place. Anyone has any idea what it might be?

 videojs("video", { "controls": true, 
                   "preload": "metadata", 
                   "poster": "<?= $video->getThumbnail($json); ?>", 
                   textTrackSettings: false, 
                   aspectRatio: '16:9', 
                   fluid: true,
                   html5: { nativeTextTracks: false }, 
                   plugins: { 
                    videoJsResolutionSwitcher: { 
                      default: "high",
                      dynamicLabel: true 
                    }
                  }
                }, function() {
                    this.updateSrc([<?= $video->printSources($json); ?>]);
                    this.on('resolutionchange', function(){
                      console.info('Source changed to %s', this.src());
                    });
                  });
  • 1

    And what would that be $video->printSources($json)?

  • It would be, in php, to print a string. Code: https://hastebin.com/huxowazipu.php

  • Yes, but what is the result of this code? By the way, this code is in a PHP file or in a JS file?

  • Result: https://hastebin.com/irekufozen.css Is in a . php file, inside <script>

  • And in which line did the error occur?

  • Here’s the problem... no line of error, what the console says is this: http://prntscr.com/fdmeo5

  • @Andersoncarloswoss really wanted to know what the function this.updateSrc() expects to receive...

  • https://hastebin.com/ecosehunuv.scala

  • @Andersoncarloswoss php replaces this by whatever and leaves it between keys?

  • He already comes between keys, he leaves between brackets

  • That’s what I meant - I confuse the two... :( You already "hardcoded" those two parts of php in the code and saw if it runs?

  • Yes, and there’s that mistake...

  • What is the entire JS code (already loaded in the page, without PHP in the middle)?

  • This is printed on page https://hastebin.com/awitalezom.js

  • Complete code: https://hastebin.com/wigavikibi.xml

  • The JS files in head are all being loaded correctly?

Show 11 more comments

2 answers

1


The problem is in Urls:

The files do not exist on the server, their path must be wrong, this error message:

Syntaxerror: Unexpected token <

Because probably when trying to load is downloaded the error page which is an HTML and the first character found is the < on the line:

<div class="container not-found">

The Javascript engine tries to "parse" and finds the < of <div, right after the error. To resolve fix the Urls, or if they are correct then it must be because you did not properly upload or some folder or file name is capitalized, when they should be minuscule letters.

-1

Your application is probably expecting a JSON response, but it is receiving HTML (probably an error page). If possible, check the backend logs.

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.