Uncaught SyntaxError: Unexpected token 'var' [duplicate] - javascript

This question already has answers here:
Uncaught SyntaxError: Unexpected token var
(3 answers)
Closed 2 months ago.
I am receieving the following error when my site loads:
Uncaught SyntaxError: Unexpected token 'var'
I am using Elementor and it has something to do with the admin-ajax.php
Does anyone know how to rectify this error. Many thanks.

It has to due with the "patt" variable at line 3034. Your slashes are commenting out everything so the browser sees this:
var patt =
var result = oldUrl.match(patt);

JS expects a value after equal sign which is not given. Your problem will be solved when you uncomment [0-9] at line 3034
var patt = [0-9];

Related

Uncaught SyntaxError: Expected ':' after property name in JSON (double quote in the string)

I have this trouble on this json array and i can't parse it:
JSON.parse("[{\"<\":\"<\"},{\">\":\">\"},{\"&\":\"&\"},{\"'\":\"'\"},{\"\"\":\""\"}]")
VM1622:1 Uncaught SyntaxError: Expected ':' after property name in JSON at position 59
at JSON.parse (<anonymous>)
at <anonymous>:1:6
I found that the problem is the last block : {""":"""}. Removed it, it's solve but i have to use it absolutely..
How to solve this?
I can't find the right escaping..
Thanks

Javascript - Uncaught Error: Syntax error, unrecognized expression [duplicate]

This question already has answers here:
What are valid values for the id attribute in HTML?
(26 answers)
Need to escape a special character in a jQuery selector string
(7 answers)
Closed 2 years ago.
Edit:
I think the issue is not with concatenation itself but the special character in the id of the element I am trying to select.
Original:
I am having problem with concatenating two strings. It seems the problem is because one of the strings contains '!'. Sadly, I have no control over what that string can contain. I tried using '+' to make single string of the two before I tried concat(). But the error remains the same.
The relevant code is $('#id_online_status_'.concat(msg.id)).removeClass('text-success').addClass('text-muted');
Error is this:
Uncaught Error: Syntax error, unrecognized expression: #id_online_status_specific.YqzvRnpU!OPMxkuoFQILY
Please help with fixing this. I am not much familiar with JS in general.
change your code like this and try
$('#id_online_status_'+msg.id).removeClass('text-success').addClass('text-muted');
remove 'concat' and try with (+)

JSON.parse not working with escaped quotes [duplicate]

This question already has answers here:
JavaScript - Escape double quotes
(2 answers)
Closed 3 years ago.
The following code is throwing an error:
alert(JSON.parse('{"name":"Quick Write \"English\"","category":"qwer"}'));
/*
{
"name": "Quick Write \"English\"",
"category":"qwer"
}
*/
It says
Uncaught SyntaxError: Unexpected token E in JSON at position 23
How do I make escaped quotes work?
I believe you can use double \ instead of \
let x = '{"name":"Quick Write \\"English\\"","category":"qwer"}';
console.log(JSON.parse(x));

Javascript Syntax error: Unexpected token ILLEGAL

When i use the javascript code ( http://jsfiddle.net/TRyhK/ ) :
var test = "#[]
#[]";
I reiceive a strange error: SyntaxError: Unexpected token ILLEGAL.
Does anyone know how to fix it?
Thanks
Line feeds in string literals can be expressed with \n:
var test = "#[]\n#[]";

javascript regex error

I have this string:
£1,134.00 (£1,360.80 inc VAT)
And I am trying to extract the numbers to get the following:
['1,134.00','1,360.80']
Using the following regex pattern in Javascript:
/\d*,?\d+\.\d{2}/g
It is working fine in Chrome, but I get this error in Opera:
Uncaught exception: Syntax error, unrecognized expression: (£1,360.80 inc VAT)
Error thrown at line 75, column 784 in <anonymous function: k.error>(g) in http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js:
throw"Syntax error, unrecognized expression: "+g;
Obviously I would like it to work in all modern browsers but I have no idea what is causing this. I have also tried several other regex patterns and have looked into escape characters as I thought it might be that.
Any ideas?!
Let me know if more info is needed. Thanks
unrecognized expression: (£1,360.80 inc VAT) <= that's not an error in your regex. Your string is not being a string. Somehow it's getting mixed and interpreted as part of your javascript.

Categories

Resources