On Sun, Mar 1, 2009 at 9:59 PM, Wil Everts <wileve...@gmail.com> wrote:

>
> One of my favorite examples of this is the Flickr example on Visual
> jQuery (http://remysharp.com/visual-jquery/).
>
> $.getJSON("
> http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=
> ?",
>  function(data){
>    $.each(data.items, function(i,item){
>      $("<img/>").attr("src", item.media.m).appendTo("#images");
>        if ( i == 3 ) return false;
>      });
>    });
>  });
>
> Here you can see that each presents you with a new object (called
> item) and it's index (i) each time through the loop below for all the
> returned matches for data.items. In your example (without seeing your
> json) item.id should work fine without an index.
>

Hi Wil,

so if i understood well, having the following JSON:

> {"records":[{"id":1,"abbreviation":"fre","description":"french"},{"id":2,"abbreviation":"eng","description"
> :"english"},{"id":3,"abbreviation":"ger","description":"german"},{"id":4,"abbreviation":"svk","description"
> :"slovak"},{"id":5,"abbreviation":"spa","description":"spanish"},{"id":6,"abbreviation":"usa","description"
> :"american"},{"id":7,"abbreviation":"ita","description":"italian"},{"id":8,"abbreviation":"por","description"
> :"portuguese"},{"id":9,"abbreviation":"cze","description":"czech"},{"id":10,"abbreviation":"rus","description"
> :"russian"},null,null,null]}
>
> i should write :
   $.each(data.records, function(i,item){...});

where "data.records" is the name of my JSON result...so records (in my
JSON).
am I right ?

A>

Reply via email to