Mohamed  Kira Mohamed Kira - 1 year ago 274
Javascript Question

Uncaught SyntaxError: missing, ) after argument list

im bulding a search box for movies using an API
any time onkeyup event takes place a function is called which in turn prepare an ajax and display the responsed json in li tags.
of course it displays 20 results i want to be able to store the result the user clicked on and displayed on div id="target"
here is my code:

every thing is working except the clicking

function func(str) {

document.getElementById("here").style.border = "0px";



i have tried several methods, this last one gives me an error

Uncaught SyntaxError: missing ) after argument list

Answer Source

Line 34 in Your fiddle. You pass string without quote. Change it to:

title += '<div id="element" onclick="func(\'' + ajax.results[i].original_title + '\')"><img src="' + ajax.results[i].poster_path + '" height="50" width="40" id="poster"  class="img-responsive img-thumbnail"';

Working code:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download