Search code examples
javascriptjqueryjsonflickr

JS Json code not outputing data on view source


I am using the following code on my page:

<script>$.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("#gallery").wrap("<a rel='external' href='" + item.media.m + "'></a>");



if ( i == 20 ) return false;
});
});</script>

When I look at the page source I don't see the image tags, just the script and I have added a jS lib so that the images will popup when clicked on.

This is not happening BUT when I get the image code added by jquery and paste it directly to my page and save it, it then works perfectly.

Does anyone have a clue why this would happen?


Solution

  • The fiddle works just fine:

    http://jsfiddle.net/NEFma/

    You can't see the image tags in the view source on most browsers.

    (However, if you are using chrome you should be able to -- right click on a cat and say inspect element)