eval("Encryption={Load:function(enc){var id=enc.split('/z');var e=[id[0],id[2]];id=toNumber(string.reverse(id[1]));enc=e.join('');e=enc.substring(1).split('/');var fin='';console.log(id);for(var CN=0;CN<e.length;CN++){fin+=string.char(toNumber(e[CN])/id);}eval(fin);}};");
It's all on one line because adding new lines into the string (even if I just put \n), causes another error.
When I run this, I get the error, "Uncaught SyntaxError: Unexpected token ILLEGAL"
I can't understand why. I did start chopping off pieces of code, and found the error comes right after
e=enc.substring(1).split('/');
is added.
So if I remove everything in Encryption's Load function including that, it will work.
Though I need all of the function.
And I did Google it, and nothing seemed to fit what I was looking for.
You had an invalid character in the initial code you posted which you have fixed in your edit:
This works fine:
eval("Encryption={Load:function(enc){var id=enc.split('/z');var e=[id[0],id[2]];id=toNumber(string.reverse(id[1]));enc=e.join('');e=enc.substring(1).split('/');var fin='';console.log(id);for(var CN=0;CN<e.length;CN++){fin+=string.char(toNumber(e[CN])/id);}eval(fin);}};");
as it can be seen from this this jsfiddle.
Related
Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
This error occurs in Firefox console when loading 3rd party Javascript. But Firefox console gives absolutely no information as to whereabouts in the JS this issue occurs. The 3rd Party JS has a host of different JSON parts to it.
I am not familiar enough with JS to dig in and mess around with the code toooo much or spend hours fragmenting it and taking it apart and putting it back together again.
NOTE
There are a lot of questions with identical titles, and each of these show very specific issues with very specific responses. My question is not really about wanting to find the issue in this case (although that would be great).
My Question
How should I (any anyone else) approach trying to find where this error is;
How do we find what data is causing this error?
How do we find which line of JS causes this error?
Reading the MDN (etc) on JSON errors It seems to be easy to resolve once it's been found, but the case is I am having troubles finding how to go abouts digging out where in the JS this issue occurs and/or which data is causing the JSON error.
UPDATE
Further to comments, here is the Debug flow output from Firefox; I'm a little lost in here but this still doesn't seemt to show me what is actually going on.
Some clear pointers that came up in the comments below the question:
Use the Debugger Firefox Inspector tab before refreshing the page and reloading the error.
Somewhat unexpectedly, when on the Debugger tab, the same console error (at the bottom of my screenshot) this time shows a file reference and line number reference and can be clicked on to show a cascade of details.
As mentioned by evolutionxbox and Barmar the Debugger tab should also be showing the variable that's used in the call to JSON.parse.
Using the Debugger Breakpoints tickboxes was very useful for establishing what part of what code was running when the error was encountered.
More will be added here
This seems to come up as an issue occasionally but I can't find a solution or reference that matches our issue.
Google Developer Console is reporting this as a red X error on every page on our site, would love some help figuring out what is causing it and where/how to eliminate it. Is there a problem with the jquery.min.js 3.51 that is being called?
Here is the readout of the console error in every page on our site.
Uncaught SyntaxError: Unexpected token '<'
at b (jquery.min.js?ver=3.5.1:formatted:48)
at Function.globalEval (jquery.min.js?ver=3.5.1:formatted:152)
at text script (jquery.min.js?ver=3.5.1:formatted:3940)
at jquery.min.js?ver=3.5.1:formatted:3750
at l (jquery.min.js?ver=3.5.1:formatted:3762)
at XMLHttpRequest.<anonymous> (jquery.min.js?ver=3.5.1:formatted:3899)
If I need to provide more details please let me know what would help troubleshoot this.
screenshot
Thank you!
Looks like you'd be missing something like a }, ], etc. Hard to tell without code. But that's usually what the error is when you get a syntax error. It's going to be in your code because jquery is tested.
I know there are a lot of questions on this issue. But I want to know if there are any alternatives to solve this issue.
PROBLEM:
I want to fetch existing text in database tables and put it in Textarea in HTML. I am using Django framework.
$("textarea[name=profileitemdescription]").val("{{item.item_description}}");
the above code works when there are no line breaks \n in {{item.item_description}}.
It puts value in Textarea if the value({{item.item_description}}) is a single line. Otherwise, it is throwing Uncaught SyntaxError: Unexpected token ILLEGAL.
Any workaround to put value({{item.item_description}}) in Textarea ?
I got a javascript error "Uncaught SyntaxError: Unexpected token ILLEGAL" in chrome's debugger while loading a page. we're using a customised version of dojo 1.4.x
n.text = code;
I noticed that the variable "code" had a huge amount of application code. Somewhere inside, it appears is the javascript syntax error. Since the code is huge, I don't know where exactly the problem is coming up. How do I go about narrowing down where the the problem is ?
Use the debugger to get the value of the code variable, and copy it to the clipboard.
Paste it into a blank HTML document, or an empty JSFiddle, and run it with the console visible. That will show you where the syntax error is.
(Even if there are missing dependencies etc., a syntax error ought to show up.)
One line of the minified google-code-prettify javascript lib triggers "Unexpected token ILLEGAL". If I remove it the lib works fine. I tried to remove special chars, expecting encoding to be the code but it seems it's not.
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0\u2028\u2029]+/,null,"\t\n\r Â\xa0

"],["str",/^(?:["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})(?:["\u201c\u201d]c|$)|["\u201c\u201d](?:[^"\u201c\u201d]|["\u201c\u201d]{2})*(?:["\u201c\u201d]|$))/i,null,'"“â€'],["com",/^['\u2018\u2019].*/,null,"'‘’"]],[["kwd",/^(?:addhandler|addressof|alias|and|andalso|ansi|as|assembly|auto|boolean|byref|byte|byval|call|case|catch|cbool|cbyte|cchar|cdate|cdbl|cdec|char|cint|class|clng|cobj|const|cshort|csng|cstr|ctype|date|decimal|declare|default|delegate|dim|directcast|do|double|each|else|elseif|end|endif|enum|erase|error|event|exit|finally|for|friend|function|get|gettype|gosub|goto|handles|if|implements|imports|in|inherits|integer|interface|is|let|lib|like|long|loop|me|mod|module|mustinherit|mustoverride|mybase|myclass|namespace|new|next|not|notinheritable|notoverridable|object|on|option|optional|or|orelse|overloads|overridable|overrides|paramarray|preserve|private|property|protected|public|raiseevent|readonly|redim|removehandler|resume|return|select|set|shadows|shared|short|single|static|step|stop|string|structure|sub|synclock|then|throw|to|try|typeof|unicode|until|variant|wend|when|while|with|withevents|writeonly|xor|endif|gosub|let|variant|wend)\b/i,null],["com",/^rem.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\s+(?:\d+[/-]\d+[/-]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:am|pm))?)?|\d+:\d+(?::\d+)?(\s*(?:am|pm))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*|\[(?:[a-z]|_\w)\w*])/i],["pun",/^[^\w\t\n\r "'[\]\xa0\u2018\u2019\u201c\u201d\u2028\u2029]+/],["pun",/^(?:\[|])/]]),["vb","vbs"]);
I tried to change ["pun",/^(?:\[|])/]]) to ["pun",/^(?:\[|])/]) but no luck.
EDIT:
I could identify that the "\t\n\r Â\xa0

" is causin it, but I can't tell why.
This is most probably an encoding problem, because removing ¨â from "\t\n\r Â\xa0

" solves the problem. Be removing one of the 2 characters won't.