Uncaught SyntaxError: missing after argument list [closed] - javascript

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.

Related

javascript/jquery syntax differences, declaring new a variable [closed]

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();

Javascript String.prototype unexpected token [closed]

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

AJAX connection with PHP file by XMLHttpRequest() [closed]

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
I want to control the answers in my form
I received this error:
Notice: Undefined index: $y2,$y3,$y4,$y5,$y6,$y7,$y8,$y9,$y10 in C:\Server...file.php on line 9,10,11,12,13,14,15,16,17
How to return "n" from PHP file?
HTML:
The problem is this line:
xmlhttp.open("GET","file.php?y1="+x1+"$y2="+x2+"$y3="+x3+"$y4="+x4+"$y5="+x5+"$y6="+x6+"$y7="+x7+"$y8="+x8+"$y9="+x9+"$y10="+x10,true);
You're separating your GET parameters with $ instead of &, so it's all ending up as one big parameter y1, and hence y2-y10 are undefined.
You need to separate your parameters like so:
xmlhttp.open("GET","file.php?y1="+x1+"&y2="+x2+"&y3="+x3+"&y4="+x4+"&y5="+x5+"&y6="+x6+"&y7="+x7+"&y8="+x8+"&y9="+x9+"&y10="+x10,true);

What is correct syntax for Jquery done()? [closed]

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) });

String and Uncaught Error: Syntax error, unrecognized expression [closed]

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 ;)

Categories