SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Location
    Malaysia
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning value from function

    Code:
    function commentCount(feedUrl){		
    	
    	var feed = new google.feeds.Feed(feedUrl);
    	var count;
    
    	feed.load(function(result) {
    		count = result.feed.entries.length;
    		return count;
    		
    	});
    	
    	return count;
    	
    }
    I would like the commentCount function to return a value, which is the variable count, however I couldn't get it done, the function returns "undefined" everytime.
    Is there any workaround on this? Any help would be appreciated~~

  2. #2
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alert your count and see what you get. I suspect that this piece of code is not executing at all.
    Code:
    feed.load(function(result) {
    		count = result.feed.entries.length;
    alert(count);
     	return count;
    		
    	});
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •