$.each(data.feed.entry, function(i, entry){

     var postlink = [];  // empty array

     $.each(entry.link, function(j, link){
          if(link.rel == "self"){
               // add to array
               postlink.push(link.href);
          }
     });

     alert(postlink.join(', '));
});

On Oct 22, 8:02 pm, rob <rob.sche...@gmail.com> wrote:
> I'm having some problem with return value for a function.  I have read
> some postings about this, but I'm just not understanding something.
> Hopefully somebody can help me with this....
>
> I'm trying to access google blogger's API to display blog entries on
> my site.  I'm doing this through JQuery and requesting a JSON
> response.  Everything seems to work ok, but I want to access the link
> for the blog entry.  This is a subset of the "entry" object.  It's
> structured like this:
>
> entry:
>      title,
>      content,
>      link:
>           rel,
>           type,
>           href,
>
>           rel,
>           type,
>           href,
>
> I want to get the link where the "link.rel == "self".  To do this I
> have to loop through the link object (5 times).  The loop and
> conditional statement works correctly, but I can't get the variable
> inside this loop back to my original function.
>
> I have this code:
>
> $.each(data.feed.entry, function(i, entry){
>
>      $.each(entry.link, function(j, link){
>           if(link.rel == "self"){
>                var postlink = link.href;
>                alert("link : " + postlink);
>                return postlink;
>                }
>      });
>
>      alert(postlink);
>
> });
>
> Thanks for your help in advance.

Reply via email to