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 trial

JavaScript AJAX Basics (retiring) AJAX and APIs Stage 4 Challenge Answer

My code is not working at all :(

$('form').submit(function (evt) { console.log('hola'); evt.preventDefault (); var $tag = $('#seacrh'); var url = 'http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?'; var data = { tag: $tag, format:"json" } console.log('hola'); console.log($tag); console.log(data); function callback (response) { console.log(data); $.each(response, function (i, photo){ photosHTML = '<li class = "grid-25 tablet-grid-50">'; photosHTML += '<a href = " ' + photo.media.m + '" ></a></li>'; }); $('#photos').html(photosHTML); } $.getJSON(url, data, callback); });

Nothing is running, not even the console logs are working. I think it is obvious that the problem is the event listener because if I console.log out of it, it works. But I can-t see any difference between my code and Dave's code. :(

you loading jquery?

deebird Yes I am loading Jquery :(

3 Answers

Upon a quick test I get your console.log when I wrap it in a doc ready

LOL. Thank you man!

James MacDonald
James MacDonald
Courses Plus Student 6,268 Points

Does your code actually start with the word "JavaScript"? Also, you're missing a semicolon after

var data = { tag: $tag, format: "json" }

Fixed it already, but still it doesn't solve the main problem. I can't even log anything inside the event listener $('form').submit(function (evt) {});

I don't understand why.