My javascript was working properly and then all of the sudden it wasn't. Chrome give me the Uncaught SyntaxError: Unexpected token ILLEGAL error on line 1 of my JS file called para2.js. I removed script from the file except for the following and I still get the error:
$( window ).ready(function() {
});
My jQuery file is included in the head of my document:
<script src="../shared/jquery.js" type="text/javascript"></script>
<script src="js/para2.js" type="text/javascript"></script>
When I look at my js file in Chrome developer tools on the Sources tab, it displays the script in Chinese:
兪敵祲搨捯浵湥⥴爮慥祤昨湵瑣潩⡮笩⥽
When I view the source of the js file, it looks fine. I have read similar posts that say copy and pasting from JSFiddle can include some hidden characters that may cause it, but I have started from scratch writing this file from a blank text file and copy and pasting nothing. It is strange that it was working and now it is not. Did my server get hacked or something? And help is appreciated.
Chrome DevTools now supports more than 80 languages, allowing you to work in your preferred language! Open Settings, then select your preferred language under the Preferences > Language dropdown and reload DevTools.
Reverting all DevTools settings to the defaults ) button, or press F1 . On the left, make sure the Preferences page is selected. At the bottom of the Preferences page, click the Restore defaults and refresh button.
The main uses of the Chrome DevTools Console are logging messages and running JavaScript.
You should use the charset
attribute to indicate which charset you are using.
<script src="../shared/jquery.js" type="text/javascript" charset="UTF-8">
I had the same problem with jquery-1.5.1.min.js. Chrome kept evaluating it as Chinese (scripts worked fine in IE). I finally solved the problem by re-encoding the .js files using "convert to UTF-8" in Notepad++. Note, not UTF-8 without BOM, but UTF-8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With