最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Illegal Character error in jQuery - regardless of function content - Stack Overflow

programmeradmin0浏览0评论

First of all, I've done my research and I did find a bunch of simialr questions. However, I didn't find an answer that applies to my problem. All the examples I found were related to unescaped characters, single/double quote mishaps and the like. I on the other hand am getting this error on the following function:

$('.seq_input').blur(function(){
    //var id = $(this).data('id');
    //var index = parseInt($(this).val()),
    //element = $("#test-list li").eq(id).remove();
    //$("#test-list li").eq(index - 1).before(element); // -1 because users like 1 based indices

    alert('what?');
      })​​​;

As you see I mented out everything and just left an alert, and I'm still getting the error, pointing to the last line of the function. It couldn't have anything to do with other functions because I just added this one alone at the end of my current Javascript.

Can someone please tell me what's going on here? Why on Earth would a function that just alerts something (or even if it doesn't do anything) give an error?

NOTE: error is shown as soon as the page is loaded

First of all, I've done my research and I did find a bunch of simialr questions. However, I didn't find an answer that applies to my problem. All the examples I found were related to unescaped characters, single/double quote mishaps and the like. I on the other hand am getting this error on the following function:

$('.seq_input').blur(function(){
    //var id = $(this).data('id');
    //var index = parseInt($(this).val()),
    //element = $("#test-list li").eq(id).remove();
    //$("#test-list li").eq(index - 1).before(element); // -1 because users like 1 based indices

    alert('what?');
      })​​​;

As you see I mented out everything and just left an alert, and I'm still getting the error, pointing to the last line of the function. It couldn't have anything to do with other functions because I just added this one alone at the end of my current Javascript.

Can someone please tell me what's going on here? Why on Earth would a function that just alerts something (or even if it doesn't do anything) give an error?

NOTE: error is shown as soon as the page is loaded

Share Improve this question asked Jun 17, 2012 at 9:49 sveti petarsveti petar 3,79714 gold badges77 silver badges158 bronze badges 2
  • possible duplicate of SyntaxError: Invalid character '\u8203' – Rob W Commented Jun 17, 2012 at 9:52
  • Easy solution here: stackoverflow./a/21903815/327862 – Mukesh Chapagain Commented Oct 6, 2016 at 7:56
Add a ment  | 

2 Answers 2

Reset to default 6

There are invisible characters between the trailing semicolon and the parenthesis. I concatenated your code, put it in a string, and called a non-existent function in order to trigger a error (using this method).

'})​​​;'.l()
>>> TypeError: "})\u200B\u200B\u200B;".l is not a function

$('.seq_input') may used on the other functions, try using new id to do that function.

发布评论

评论列表(0)

  1. 暂无评论