syntax error codepen full view

i'm trying to complete the wikipedia search for freecodecamp,(in codepen), and i'm running into this problem where my code will run in codepen's edit view and debug view, but fails to run in, "details view",and "full view". The error given in the console in details, and full view, is,

"Uncaught SyntaxError: missing ) after argument list"

, yet jshint can't seem to find the error, and the code seems to run fine otherwise? Is it simply a codepen bug?

Here is my pen. Very sketchy. :o (editor view)(working) (full view)(not working)

    $.ajax ({
              url: prefixSearch,
              success: function(jason){
                     var prefixSearchResults= jason;

                     for(var i= 0; i<prefixSearchResults.query.prefixsearch.length;i++){
                     curid.push( ""+prefixSearchResults.query.prefixsearch[i].pageid);  queryResultsArray.push(prefixSearchResults.query.prefixsearch[i].pageid);
               queryResultUrls.push("<a rel="nofollow" rel="noreferrer"href= '"+prefixSearchResults.query.prefixsearch[i].pageid+">"+prefixSearchResults.query.prefixsearch[i].title+"</a><br>"+prefixSearchResults); 

//here the "Uncaught SyntaxError: missing ) after argument list" error occurs.

Any ideas?

Answers 1

  • An alternative to escaping the quotes like @subwaymatch pointed out, you could just use single quotes here

    queryResultHrefLink='<a href="'+prefixSearchResults.query.prefixsearch[i].pageid+'">'+prefixSearchResults.query.prefixsearch[i].title+'</a><br>'+prefixSearchResults;

Related Articles