Javascript html string concatenation Uncaught SyntaxError: missing ) after argument list

uncaught syntaxerror missing ) after argument list onclick
uncaught syntaxerror missing ) after argument list jquery
syntaxerror: missing ) after argument list npm
uncaught syntaxerror: missing ) after argument list wordpress
syntaxerror: missing ) after argument list in while compiling ejs
syntaxerror: missing ) after argument list async
uncaught exception syntaxerror: missing after argument list mongodb
syntaxerror: missing after argument list jest

Does anyone know what I am missing here? Aparently, the error come from show_more('+ link +') Uncaught SyntaxError: missing ) after argument list

    function show_more(mylink) {
        console.log(mylink);
        alert(mylink);
    }

The problem is a missing double quote. You have:

html += '... onclick="show_more('+ link +')">...'

You have a global string in single quotes, in which you define the value of attribute 'onclick' in double quotes, into which you will have the value of your link, raw, between your round brackets.

You should add -quotes- escaped single quotes:

html += '... onclick="show_more(\''+ link +'\')">...'

SyntaxError: missing ) after argument list, Because there is no "+" operator to concatenate the string, JavaScript expects the argument for the log function to be just "PI: " . In that case, it  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.

Why not use template string, will make string formation much more simple and easy. Take a look at below snippet.

In current code, some quotes are missing show_more("'+ link +'") try avoid this approach altogether.

function getImages(index, stop) {
  var html = "";
  currentIndex += stop;
  // create the img tags.
  for (var i = index; i < index + stop; i++) {
    var link = "http://31stbridge.com/godson_project/uploads/" + images[i].photo_url;
    html += `<div class="grid-item"><a href="#" onclick="show_more('${link}')"><img src="http://baseurl/path/${images[i].photo_url}"></a><div class = "subtitle" align="center"> <h1>${images[i].photo_group}</h1><form><button class="downloadbut" formaction="${images[i].zip}"></button></form></div></div>`;
  }
  var str = $(html);
  grid.append(str);
  grid.masonry("appended", str);
}
});

JavaScript Error Handling: SyntaxError: missing ) after argument list, The Missing Parenthesis After Argument List error can occur for a A very typical action in JavaScript is to concatenate multiple strings together to form one larger string. Uncaught SyntaxError: missing ) after argument list. Uncaught SyntaxError: missing ) after argument list As you may notice, we passed two arguments to console.log() , but we did not separate them by a typical comma ( , ), nor did we concatenate our two string values together with one of the above methods.

Extra brackets at the end gives you unexpected error in the console

function getImages(index, stop) {
    var html = "";
    currentIndex += stop;
    // create the img tags.
    for (var i = index; i < index + stop; i++) {
      var link = "http://31stbridge.com/godson_project/uploads/" + images[i].photo_url;
       html += '<div class="grid-item"><a href="#" onclick="show_more("'+ link +'")"><img src="http://baseurl/path/' + images[i].photo_url + '"></a><div class = "subtitle" align="center"> <h1>' + images[i].photo_group + '</h1><form><button class="downloadbut" formaction="' + images[i].zip + '"></button></form></div></div>';
    }
    var str = $(html);
    grid.append(str);
    grid.masonry("appended", str);
  }
   

JavaScript Errors - SyntaxError: missing ] after element list, Next up in our adventure through the JavaScript Error Handling series we'll be In this article we'll explore the Missing Bracket After Element List error in New Array object, with arguments. var namesB = new Array('Alice', 'Bob', 'Chris', CHROME Uncaught SyntaxError: Unexpected string // FIREFOX  (a) concatenating strings as you have done does not require additional slashes; (b) only if you try to line break up a string literal (which is not the case), then you should use the backslash (\). – Manngo Mar 23 '17 at 6:05

Uncaught SyntaxError: missing ) after argument list, Uncaught SyntaxError: missing ) after argument list. Console log says ----> "quiz.​js:46" So apparently there is a missing ')' on line 46. 46 BELOW //missing two + operators between playerName and string //and one between immediately following playerName to signify that there is further concatenation. But from JavaScript's perspective, they aren't. The problem is with the string in the document.write() in the else part of the statement. You began the string with a single quotation mark, so when it gets to the apostrophe (which is the same) it thinks that is the end of the string and is, of course, expecting a closing parenthesis immediately after. Take a look.

Understand JSON - Part 2: Parse JSON with JavaScript, as a massive concatenation of characters (one huge string) with encoded strings Since JSON was derived from JavaScript and its syntax is a subset of the the well formed JavaScript Object Notation(JSON) string into an object. firstName);//Uncaught SyntaxError: missing ) after argument list (line 8)  Uncaught SyntaxError: missing ) after argument list “Uncaught SyntaxError: missing ) after argument list” em .append JQuery. 4. Botão de Link no Slideshow

Uncaught SyntaxError: missing ) after argument list throwing error in , Uncaught SyntaxError: missing ) after argument list throwing error in html line. Posted on June 6, 2018 by Ram. can anyone tell me what's wrong in this line? E eu acho que isso pode acontecer devido a esse erro no javascript ( mas como não tenho certeza se o que está causando o problema é o erro, separei a pergunta para não ficar confuso): Uncaught SyntaxError: missing) after argument list. Este é o javascript

Comments
  • Try to avoid using inline event handlers.
  • You are missing quotes around the url parameter for show_more. But @undefined is also correct - you can avoid that.
  • thank Saucistophe, but I got (index):1 Uncaught ReferenceError: show_more is not defined
  • Then you need to ensure that your function definition is accessible to your listener. Since yoou edit your HTML directly, you need to make sure that show_more is accessible to the global scope. You can do that by opening your browser's dev tools, and in the console, type in window.show_more. If you get "undefined", then you have your error.
  • my bad.. you were right, I have somehow mis-typed the function name. the escape single quote resolved the issue.
  • @AbbeyOla did you try the template string approach, it has been updated and should be working.
  • thanks Shubham .. but I get same error with your code. what exactly did you add or remove from mine?
  • I have removed string concatenation entirely and used template string. See of I have missed some paranthesis here or there. But this is how you should create strings when lots of var are involved. Check what string is being formed and if it has quotes around the link.
  • @AbbeyOla what we missed was quotes, earlier it was "show_more(${link})" but it should be "show_more("${link}")". Updated the answer check if this works now.
  • @AbbeyOla added working snippet. Sorry for trouble "show_more('${link}')" replace the double quote around link to single quote. Updated your function code block as well.
  • The call to show_more is still incorrect in the inline handler.
  • yes, I can confirm @vlaz is correct ... the error persist
  • no @MonicaAcha , this doesnt work ... the variable 'link' was translated as string in your new answer and I got the following error. Uncaught SyntaxError: Unexpected string
  • Have a look at the edited code. You can also use escape characters to avoid confusions.