turnt
turnt

Reputation: 3255

Why is this Flickr API with jQuery Code not working?

So I'm really new to APIs, and I'm trying to use jQuery with this tutorial code I saw on the net today. I'm working in jsFiddle: http://jsfiddle.net/shrimpboyho/Pg5kG/

Here's the code:

alert("Using Flickr Api"); 

$.getJSON(
    "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", 
    {
        tags: "mount rainier",
        tagmode: "any",
        format: "json"
    },
    function(data) {
        $.each(data.items, function(i,item){
            $("<img/>").attr("src", item.media.m).appendTo("#images");
            if (i == 3) 
                return false;
        });
    });                

And here's the HTML:

<html>
    <head> Flicker Api</head>
    <div id= "content"></div>
    <body></body>
</html>

Why is this not working?

Upvotes: 2

Views: 469

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337701

Your HTML is invalid:

  • You can't put a div outside of the body.
  • Flicker Api should be inside a <title> tag.
  • You're appending to #images, but the div is called #content.

Once you've sorted those issues, it should work:

Updated fiddle

Upvotes: 3

Related Questions