How to to send and retrieve data from flickr flickr.test.echo method using JQuery Ajax REST?

23,106

Solution 1

Use Flickr's JSON format API and jQuery.getJSON like sktrdie suggested - just remember to append callback=? to the url to wrap it in JSONP.

From the jQuery.getJSON docs:

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

Solution 2

I'm not sure how you're going to retrieve their data with Ajax, since Ajax doesn't work cross-domain.

Have you seen their $.getJSON demo? http://docs.jquery.com/Ajax/jQuery.getJSON

It lets you specify a callback and returns json wrapped as a parameter inside an automatically generated function. It works cross-domain as well.

Share:
23,106
Admin
Author by

Admin

Updated on February 02, 2020

Comments