Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have this code, where getURLParamter returns the value of a url parameter and I use that value to select on an input.
var urlParam = getURLParameter('a'),
selectedInput = $('input[id="custom-156[' + urlParam + ']"');
This has worked without problem through many rounds of cross-browser testing. However, there have been sporadic error reports from users including, finally, a co-worker. Chrome's console showed this error:
Uncaught Error: Syntax error, unrecognized expression: input[id="custom-156[1]"
My coworker uses the same model computer and the same version of Chrome. I don't have this error but he does. Why would this be and what is the cause of the error? I think it is a problem with the single double quotes within the pair of single quotes. What is a better way to write this?
There is no closing square bracket on the selector. you'll need
input[id="custom-156[' + urlParam + ']"]'
For the points ;)
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
My code in javascript causes an error at the following line:
var tries:int=GetCallAttemptCount();
The error message says Error in Script Unexpected token : , Line 3
Line 3 is where the error appears. The script was originally in jquery, so I wonder is there a difference in how a variable is declared in Javascript and Jquery?
I'm computer literate, but I am a beginner with Javascript.
Thanks all, Adam
That's not javascript, this looks like typescript, in JS:
var tries = GetCallAttemptCount();
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Apologies if this has been asked before but I couldn't find this specific issue.
I've been tasked with analysing a bit of highly obfuscated, and malicious, JS code. I'm trying to get it to run in a VM at the minute just to see exactly what it's up to but I'm getting a syntax error on the first line.
function String.prototype.x(){...
From Chrome's dev console:
Uncaught SyntaxError: Unexpected token .
The red squiggly line shows that the error is being thrown at the first dot (between String and prototype). To be honest, I don't know enough about JS to figure it out but I'm sure one of you lovely lot will know the answer. Why's it thrown and what can I do to fix it?
String is already a class (function with the inbuilt prototype methods) in JS , in order to create methods in its prototype chain you have use as below
String.prototype.reverse = function(){
return this.split('').reverse().join()
}
"hello".reverse() // olleh
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I need to add class to all the links that have "href=login". And i tried to use this javascript
jQuery(document).ready(function($){
$(.pageWidth).find('a[href*="/login/"]').addClass('OverlayTrigger');})
Unfortunately, i tried so many times and it always getting this error
Uncaught Syntax Error: Unexpected token
How can i fix this? What's the problem here?
Thank you!
You are missing quotes in your jQuery selector:
jQuery(document).ready( function($) {
$('.pageWidth').find('a[href*="/login/"]').addClass('OverlayTrigger');
} )
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Below is the parsed html of button. Basically, it's inside the datagrid.
When I click on this button it gives me console error:
Uncaught SyntaxError: missing ) after argument list
<button onclick="myFunction(javed#gmail.com)">Click</button>
Here is the scripting for click event.
function myFunction(e) {
alert(e);
}
You need to pass the email as a string, otherwise, it will be parsed as javascript
<button onclick="myFunction('javed#gmail.com')">Click</button>
Note, not all parameters need to be strings. Passing a number, function, object,or variable without quotes is valid.
If you do not include quotes, thats what the parser will assume your trying to pass but will fail if the parameter is neither of those.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have the following syntax:
And am receiving the following error on line 6:
Uncaught SyntaxError: Unexpected token {
I read the api docs on done() and I can't see what I am doing wrong here.
$.post(path).done(funtion(data) { ....
^----notice any missing characters here, a "c" perhaps?
JS is trying to call a function called "funtion", which means that the { afterwards is illegal syntax. Since it parses out that syntax error first, it doesn't get to the point of being to able to tell you that "funtion" doesn't exist.
You wrote funtion instead of function.
$.post(path).done(function(data) { console.log(data) });