4

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 commented 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

sveti petar
  • 3,637
  • 13
  • 67
  • 144

2 Answers2

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
Community
  • 1
  • 1
Rob W
  • 341,306
  • 83
  • 791
  • 678
  • @robert I've removed these invisible characters, and no error is showing up any more. Start at the semicolon at the very end, press backspace four times, then enter the semicolon again. – Rob W Jun 17 '12 at 09:56
  • I did, there were indeed invisible characters there. but it didn't help. I then tried removing the function completely and re-typing it and the error is still there. I don't get it. – sveti petar Jun 17 '12 at 09:57
  • @robert Then you've got more invisible characters in your code. If you're using Firefox, you can use E4X to quickly stringify your code, and trigger the error: `...code here....toString().l();`. Otherwise, use a hex editor to view your code. – Rob W Jun 17 '12 at 09:59
0

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

nsgulliver
  • 12,655
  • 23
  • 43
  • 64
nazwie
  • 1