Come across this once in awhile.
Unpacked a zip file sent to me by a coworker. Loaded it up on my tomcat server to find out that there's this weird question mark at the beginning of the included JS file, preventing the JS file from being included properly.
I resaved the HTML file and the JS as new files and made sure encoding was UTF-8 and the line breaks were UNIX style.
Now I see the "ILLEGAL Token" error in Chrome and FF. Any ideas why?
EDIT:
Adding JS that is causing the issue. Anything inherently wrong with this? Per a comment, I think the removal of BOM fixed the issue but still getting the "ILLEGAL Token" message.
if(typeof deconcept=="undefined"){var deconcept=new Object();}
Hard to say with much confidence, but weird characters at the start of text files are very often the Byte Order Mark (BOM). See http://en.wikipedia.org/wiki/Byte_Order_Mark. Some software handles them well, and you see nothing, other software doesn't handle them correctly and you see weird characters.
Related
I'm playing some audios from a folder in my page, and most of them play without any issues, but when it comes to play a file with a name like "jär" i get this error:
Uncaught (in promise) DOMException: Failed to load because no supported source was found.
I don´t know if it has something to do with my web browser, I run my project on Chrome. I'm using JavaScript and JQuery
The error happens only with files that have some kind of accent or special character on its name (like ä). What I wanna do is, of course, to play such audio regardless its name. Any help is appreciated. Thank you so much.
Most likely what's happening is that your browser isn't resolving URLs with Unicode characters. When pulling your media files, try wrapping it in a encodeURIComponent(). This will format the URI according to the proper conventions, using percent encoding for special characters. For example, jär becomes j%C3%A4r.
x = 'jär'
console.log(x)
console.log(encodeURIComponent(x))
Just wanted to let you know that I finally solved my problem, it seemed I had to encode the value on ISO 8859, so all I had to do was to wrap the value in an escape clause like:
var encode = escape("jär")
And that's it. It worked like a charm. I hope this solution helps to any other who has this issue.
Strange error here: I have a page that's referencing several JavaScript files. Occasionally, the browser will complain of:
Uncaught SyntaxError: Unexpected end of input
However, it doesn't appear to be due to a missing parent, or malformed JSON. Part of the JavaScript file will load, but the program will just stop loading the rest of the file. Example: half of the file will load, with the other half missing.
Most of the time, the files load and everything works. Any idea why I would occasionally be getting this error, rather than every time (as expected with a missing paren or something similar)? Other things I can check?
EDIT:
This is a Rails project (Rails version 3.2).
The JS files are standalone, and are kept in the pub directory for dev. In other words, they are NOT included in the asset pipeline.
There must be braces not closed properly.The file stops loading whenever the error is encountered and leaves the rest part unloaded as because of error.
You can check this example here
I'm maintaining this website that accepts multi-line inputs from user and sends the data via JSON. line break \n are decoded and encoded properly but somehow the \r chars are not accepted on the server side and I have the feeling I would need to escape them prior to sending them over. Before making the fix, I want to try to reproduce the issue but I can't find a way to do it !!!!
Do you have any recommendations?
EDIT after more investigation, it turns out that the issue is in IE only ( as in the \r chars get added when copying/pasting to the text input). Hijacking the text area did not change anything in FF or chrome and doing a data.description.replace("\r","") did not solve the issue either. Still poking around.
if you just want to reproduce the error, just add some js to populate the textarea:
document.getElementById('textarea-id').value = 'test\r\ntest';
Chrome's Developer Tool's Javascript Console lets you send JSON to your server using friendly jQuery/MooTools/Protoype syntax
I'm testing out a website that runs fine on Firefox (Win/Mac), Chrome (Win/Mac) and Safari. I'm having difficulty with Internet Explorer unfortunately. I get the following error message:
SCRIPT65535: Unexpected call to method or property access.
raphael-min.js, line 8 character 64961
I've taken a look at the debug output which looks like just takes me to a part of the Raphel library:
c=a.getScreenCTM()||a.createSVGMatrix()
I've searched for this error message online, but I don't understand what solution is relevant to this case as I've no idea what is causing the problem. I am also using the jQuery library. Are there any tests that I can do that can give me more information about the source of the problem?
I just found how to patch this, in order to keep the compressed version of Raphael.
Replace (don't forget the coma):
c=a.getScreenCTM()||a.createSVGMatrix(),
By that (dont't forget the end space):
c;try{c=a.getScreenCTM()||a.createSVGMatrix()}catch(e){c=a.createSVGMatrix()};var
Works fine ! :)
Means :
c; : declaration of variable c, and stop the first instruction.
try{c=a.getScreenCTM()||a.createSVGMatrix()}catch(e){c=a.createSVGMatrix()}; : our instruction, surrounded by a try/catch, to avoid IE error
var + a space : (don't forget the space!) allow us to continue to declare variable
I found out that it's an issue with compression (of the js file). I had the exact same issue and I had been searching for a solution. Guess what? I tried it with the uncompressed Raphael file and voila! No more issues. Compressed file needs a tweak, it seems.
I am editing an existing site, which is a typical merchant site. A series of PHP files with one main index that loads in the various content pages.
The main index.php, using <script>, loads in jsFunctions.js.
When ever I modify the jsFunctions.js file, the index only loads the jsFunctions.js partially. For example I will get a firebug error such as 'unterminated string literal' or 'missing end }' or similar. The errors themselves make sense, because the js file isn't fully loading, a brace or quote is missing and throwing an error. It is seemingly random, sometimes it will load 100 lines of the js, then sometimes 105 lines, etc.
But why would the file be partially loading if i edit it? If i remove the single line of my code, no matter how simple, it starts working again?
Any ideas?
Are you editing a file with inconsistent line-endings, which editor? Issues like line-ending or weird unicode characters cause the issues like you've described.
I would take the contents of the file after your edit do a copy/paste exact as it is to JSLint: http://www.jslint.com/
JSLint is a validation tool for your script, before checking for best practices though, it'll check that your script is valid at all. See if you get the same error, it could be a weird character that's slipped in there causing issues, JSLint will alert you to this and where it's at.
Apparently it was some kind of server serving issue. If I refreshed a random amount of times, the full js would load. Once loaded it works 100% after that, well until I uploaded a new copy, then I would have to refresh a couple of times (or possibly wait 1-2 mins).
Filezilla was showing that the upload was complete, but the server simply didn't seem ready to output it.
Thanks guys