Javascript Uncaught Syntaxerror Unexpected Identifier Error
Basically, the method prints a list with values and when I click on a value, I get this error : Uncaught SyntaxError: Unexpected identifier on line 6. As a result,I am unable to pa
Solution 1:
In this line
htmlStr += '<a id="searchResult'+i+'" href="javascript:liveSearch('+arrOfSuggestText[i]+')" > '+arrOfSuggestText[i]+'</a>';
and concrete here '" href="javascript:liveSearch('+arrOfSuggestText[i]+')" > '
you try create calling function, but if you see value of this string, for arrOfSuggestText[i] == 'qwe'
you can see something like
href="javascript:liveSearch(qwe)"
and browser raise error what you get on qwe
.
So you need just add quotes around like
'" href="javascript:liveSearch(\''+arrOfSuggestText[i]+'\')" > '
Post a Comment for "Javascript Uncaught Syntaxerror Unexpected Identifier Error"