Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDerrick Johnson
4,347 PointsHow does my solution look?
Anything I can clean up on?
$('input[type="submit"]').on('click',(e) => {
e.preventDefault();
// search word to be used for flickr tag
let $searchText = $('input[type="search"]').val();
// Ajax call for images
$.ajax({
url: 'https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?',
dataType: 'json',
data: {
tags: $searchText,
format: 'json'
},
success: (images) => {
let html = `<ul>`;
$.each(images.items,(i,image) => {
html += `
<li class="grid-25 tablet-grid-50">
<a href="${image.link}" class="image">
<img src="${image.media.m}" />
</a>
</li>
`;
});
html += `</ul>`;
$('#photos').html(html);
}
});
});