Streaming live at 10am (PST)

A Simple Example of using JSON data?


#1

I'm new to webflow and I'm primarily a developer. I've searched the forums for JSON and found some partial answers but not a complete answer/example. I've also played around with putting js in the embed block and in the custom code (before the body) without much success.

Can anyone point me to a complete example of loading external JSON data?

thanks in advance,
k



#2

Here is what I was looking for:

  • Create a div and set the id to 'images' (without the quotes)

  • In the custom code panel, in the Footer Code area enter a script tag followed by:

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

This will display the most recent Flickr images of Mt. Rainier.


#3

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.