Uncaught SyntaxError: Unexpected token ILLEGAL for Chrome Browser
toggle.js
var $jq = jQuery.noConflict();
$jq(document).ready(function(){
开发者_运维问答 $jq('.isAdd').hide();
$jq("#Add_category").change(function(){
var value = $jq("#Add_category option:checked").val();
var theDiv = $jq(".isAdd");
theDiv.slideToggle("slow");
});
});
In console I had:
Uncaught SyntaxError: Unexpected token ILLEGAL
For Firefox it's works fine, but not for Chrome and Chromium for Ubuntu.
There is an invisible character following the last });
of your last line. When I pasted it into my editor, it appeared as a .
.
View your code in an editor capable of displaying non-printable characters with some kind of symbol, or view it in a hex editor.
To summarize the solution to problem with "Unexpected Token ILLEGAL":
ILLEGAL means strictly Syntax Error.
The Fix
Install HxD Editor (recommended) and open your file in it. You can detect where exactly the error is occuring by detecting unusual .
(as it happened with me), with the code's HEX representation. Save and replace the file.
@TiSer: please check your code for invisible white space chars, on document ready handler is not the problem here, it was the illegal token direct after them – Irishka Oct 14 '11 at 13:57
yeap, it's right! Incredible - one small symbol and all JS code fell. :) – TiSer Oct 17 '11 at 8:50
$jq(document).ready(...); is causing this error Chrome
move your jQuery script to the bottom before < /body > tag
EDIT: check for white spaces
精彩评论