Chris
Chris

Reputation: 12191

Missing ) after argument list in JS with JQuery

When making a feedreader in Javascript (using google's feed API) I want to use query-ui tabs to differentiate the groups, then accordions for each source in that group. I'm getting a JS error in FireBug when I try to do container.append(accordionID). Besides being unable to spell accordion, it says I am missing a right parens, but I have checked and they all seem matched up. I even moved the string creation out of the call itself to make sure that wasn't the issue.

var feeds = [
    {url:"http://feeds.feedburner.com/engadget/Dnjv",
    title:"Engadget"}
]; //

function loadFeeds(){
    for(var i=0; i<feeds.length;i++){
        var source = new google.feeds.Feed(feeds[i].url); //defaults to JSON
        source.includeHistoricalEntries();
        source.setNumEntries(10);
        source.load(function(result){
            if(!result.error){
                $("#feedsList").append("<li id='#source-"+i+"'>"+feed[i].title+"</li>"); //adds tab for source
                var container = $("#sources").append("<div id='source-"+i+"></div>"); //add source in sources section
                for(var j=0; j<result.feed.entries.length; j++){
                    var entry = result.feed.entries[j];
                    var accordianID = "<div id='accordian"+j+"'>";
                    container.append(accordianID).html("<h3><a href='#'>"+entry.title+"</a><a href=\'"+entry.link"\'> link</a></h3><div>"+entry.content+"</div></div>");
                }
            }
        })
    }
    google.setOnLoadCallback(initialize);
}

Upvotes: 1

Views: 3274

Answers (2)

user166390
user166390

Reputation:

You are missing an operator in the following line:

container.append(accordianID).html("<h3><a href='#'>"+entry.title+"</a><a href=\'"+entry.link"\'> link</a></h3><div>"+entry.content+"</div></div>");

It doesn't have to do with an "unbalanced" parenthesis directly, but since either an operator or a ) was permissible, this error is the end result.

(Which operator and where is left as an exercise for the reader.)

Happy coding.

Upvotes: 1

Andy Ray
Andy Ray

Reputation: 32076

container.append(accordianID).html("<h3><a href='#'>"+entry.title+"</a><a href=\'"+entry.link"\'> link</a></h3><div>"+entry.content+"</div></div>");

entry.link"\'> link

should be

entry.link+"\'> link

Upvotes: 6

Related Questions