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="' + + '" class=image">';
                  photoHTML += '<img src="'+ + '"></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="' + + '" 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!