JS error Uncaught SyntaxError: Unexpected token (analysis and solution)
JS error Uncaught SyntaxError: Unexpected token <Analysis and Solution
We usually encounter the following problems:
Uncaught ReferenceError: xxx is not defined
Uncaught TypeError: Cannot read property 'length' of undefined
Uncaught SyntaxError: Unexpected token ILLEGAL
However, the problem I encountered this time is: Uncaught SyntaxError: Unexpected token <
An endless loop may even occur, causing the browser to crash:
Because the debugging function of the browser cannot be used to locate the actual error location, you can only search by adding or deleting code in the binary method,
Finally, we found that the cause of the error was caused by the "eval" method, for example:
Because the address of the AJAX request must be accessed only after logon, the logon page will be displayed if you do not log on. Therefore, the HTML code of the logon page is returned, which leads to an error in executing the "eval" function;