I am getting the syntax error:
SyntaxError: missing ) after argument list
From this jQuery code:
$('#contentData').append(
"<div class='media'><div class='media-body'><h4 class='media-heading'>" +
v.Name + "</h4><p>" + v.Description + "</p><a class='btn' href='" +
type + "' onclick="(canLaunch('" + v.LibraryItemId + " '))">
View »
</a></div></div>")
What kinds of mistakes produce this Javascript Syntax error?
The "SyntaxError: missing ) after argument list" occurs when we make a syntax error when calling a function, e.g. forget to separate its arguments with a comma. To solve the error make sure to correct any syntax errors in the arguments list of the function invocation.
The “SyntaxError: missing ) after argument list” error is raised if a function call cannot be evaluated correctly. To fix this error, make sure your arguments are formatted correctly. Double-check that all of the arguments in the function call are separated by commas.
The JavaScript exception "missing ) after argument list" occurs when there is an error with how a function is called. This might be a typo, a missing operator, or an unescaped string.
You had a unescaped "
in the onclick handler, escape it with \"
$('#contentData').append("<div class='media'><div class='media-body'><h4 class='media-heading'>" + v.Name + "</h4><p>" + v.Description + "</p><a class='btn' href='" + type + "' onclick=\"(canLaunch('" + v.LibraryItemId + " '))\">View »</a></div></div>")
SyntaxError: missing ) after argument list
This code produces the error:
<html>
<body>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
}
</script>
</body>
</html>
If you run this and look at the error output in firebug, you get this error. The empty function passed into 'ready' is not closed. Fix it like this:
<html>
<body>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
}); //<-- notice the right parenthesis and semicolon
</script>
</body>
</html>
And then the Javascript is interpreted correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With