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

Roudy Antenor
Roudy Antenor
4,124 Points

photos show up BUT all disorganized?

Hello all here is my code - i opted to not use the variables and code the $.getJSON with my demands however -- i have the same code as video by photos show up with none of the styling -- any thoughts??


     let animal = $(this).text(); //get text from html elem.
                tags: animal,
                format: "json"
                let photoHTML = '<ul>';
                $.each(data.items, function(i, photo) {
                  photoHTML += '<li class="grid-25 tablet-grid-50">';
                  photoHTML += '<a href="' + photo.link + '" class=image">';
                  photoHTML += '<img src="'+ photo.media.m + '"></a></li>';
                }); //end each
                  photoHTML += '</ul>';

                } //end callback function
    ); //end .getJSON
  });// end click event handler   
}); //end ready

1 Answer

Charles Wanjohi
Charles Wanjohi
9,235 Points

The error is in this statement

 photoHTML += '<a href="' + photo.link + '" class="image">'; 
//  ensure the class=image " has the "image" value enclosed in quotes

Hope this helps you out

Roudy Antenor
Roudy Antenor
4,124 Points

Ahhhhh .... It works! Many Thanks!