开发者

Uncaught SyntaxError: Unexpected token ILLEGAL for Chrome Browser

开发者 https://www.devze.com 2023-04-13 03:18 出处:网络
toggle.js var $jq = jQuery.noConflict(); $jq(document).ready(function(){ 开发者_运维问答$jq(\'.isAdd\').hide();

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号