admin管理员组

文章数量:1421000

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:"",
    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);
}

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./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);
}
Share Improve this question edited Dec 12, 2011 at 2:11 user166390 asked Dec 12, 2011 at 2:01 ChrisChris 12.2k19 gold badges94 silver badges150 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 6
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

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.

本文标签: javascriptMissing ) after argument list in JS with JQueryStack Overflow