Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript AJAX Basics (retiring) AJAX and APIs Displaying the Photos

Loy Yee Ko
Loy Yee Ko
5,814 Points

Hi guys, I have run into this problem, I am not sure what did I do wrong. thanks for the help!

jquery-1.11.0.min.js:4 GET https://api.flickr.com/services/feeds/photo_public.gne?jsoncallback=jQuery111005584688364710975_1547524438603&tags=Dog&format=json&_=1547524438604 net::ERR_ABORTED 404 send @ jquery-1.11.0.min.js:4 ajax @ jquery-1.11.0.min.js:4 n.(anonymous function) @ jquery-1.11.0.min.js:4 getJSON @ jquery-1.11.0.min.js:4 (anonymous) @ flickr.js:21 dispatch @ jquery-1.11.0.min.js:3 r.handle @ jquery-1.11.0.min.js:3

$(document).ready(function (){
  $("button").click(function (){
    let flickrAPI = "http://api.flickr.com/services/feeds/photo_public.gne?jsoncallback=?";
    let animal =$(this).text();
    let flickrOption = {
      tags: animal,
      format: "json"
       function displayPhotos(data) {
        let photoHTML = `<ul>`;
        $.each(data.items, function(index, photo) {
            photoHTML += `<li class="grid-25 tablet-grid-50">
                          <a href="` + photo.link + `" class="image">
                          <img src="` + photo.media.m + `" /></a></li>`;
        photoHTML += `</ul>`;
    $.getJSON(flickrAPI, flickrOption, displayPhotos);
  });// button function ends
});//end ready

1 Answer

Mark Nunes
Mark Nunes
6,930 Points

The FlickrAPI is wrong. You need to change the variable for this:

let flickrAPI = "https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";

Loy Yee Ko
Loy Yee Ko
5,814 Points

oh right! thanks Mark for pointing out!