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 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.