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?
Your HTML is invalid:
divoutside of thebody.Flicker Apishould be inside a<title>tag.#images, but the div is called#content.Once you’ve sorted those issues, it should work:
Updated fiddle