0

I am getting a error when saving my php file that I have used jQuery in. I have located the exact script that gives me the error message, and also breaks the jQuery on the page. Can anyone tell what is wrong with this? I cant see why it would give me an encoding error.

$(document).ready(function() {
    var left = 0;
    $('#breadcrumbs-list > li').each(function() {
        $(this).css('left', left + 'px');
        left += 100;
    });​
});​    

Error: the document's current encoding can not correctly save all of the characters within the document. You may want to change to UTF-8 or an encoding that supports special characters in this document

patrick
  • 659
  • 3
  • 9
  • 25
  • 1
    what is relation between your post title and this code? you code seems well. – thecodeparadox May 05 '12 at 18:40
  • This script you posted is VALID and is used to displace your `li` elements at += 100 px each starting from 0px – Roko C. Buljan May 05 '12 at 18:42
  • Why do you use JS for this at all? USe CSS with proper relative positioning! – ThiefMaster May 05 '12 at 18:42
  • I am getting an error when I try to save the file(in dreamweaver) before uploading to the server to test. – patrick May 05 '12 at 18:42
  • @patrick Dreamweaver? Well there's your problem right there ;) Just playing. What is the error you're getting, and do you have jQuery referenced, perhaps the Google CDN version? – Sampson May 05 '12 at 18:43
  • @ThiefMaster, the list is dynamically generated from a CMS. I can't control the output. – patrick May 05 '12 at 18:44
  • @Jonathan... I know, I am a designer what can i say... also I am sourcing jQuery via wordpress, it is using 1.4.1 from the google library – patrick May 05 '12 at 18:47

1 Answers1

1

You have at least two illegal invisible characters in your code. From what I can tell, they're both just after the last two semicolons.

Position the cursor as far to the right of each semicolon as possible, and use backspace. You'll notice that one of the backspaces doesn't move the cursor. That's the illegal character being removed.

You can also observer this behavior without actually backspacing. Just move the cursor with the arrow keys, and again, you'll notice that when the invisible character is encountered, the cursor won't move for that one keypress.


The exact character is "\u200B" in both cases.

Here's another StackOverflow question that explains what that character is.

Community
  • 1
  • 1
cliffs of insanity
  • 3,683
  • 1
  • 16
  • 18
  • hmm, I can't seem to find it within my code. also, I am debugging with chrome, and it gives me 'Uncaught SyntaxError: Unexpected token ?' after the last line of that script – patrick May 05 '12 at 18:48
  • @patrick: What do you mean by "find it"? Like I said, they're invisible. You successfully copied the characters into the question. That's how I was able to find them. You just need to follow the instructions in my answer to remove them. It's possible that there are more as well. – cliffs of insanity May 05 '12 at 18:51
  • thanks, I just ended up re-writing the script and it solved the problem. I am wondering where this came from could it be from copy and pasting from jsfiddle? also: Thanks! – patrick May 05 '12 at 18:52
  • @patrick: Yes, that's exactly where it came from. I've encountered the same issue in the past with code from jsFiddle. – cliffs of insanity May 05 '12 at 18:53