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

Frantyk Andrii
Frantyk Andrii
35,423 Points

Code doesn't work on Workspaces

When I use Workspaces, and try to follow for the teachers, my code doesn't work when I press preview button, and it doesn't display anything. But, when I use my own text editor, it works correctly. And I have a question, why workspaces doesn't work? Sometimes it easy to use workspaces following lecturer, rather than text editor. I it can be fixed?

2 Answers

rydavim
rydavim
18,813 Points

When you try to preview and get a blank page, are you getting any errors if you look at your browser's developer tools?

It's possible it's just not updating to the newest code version. I would try closing the workspace and reopening it, refreshing the preview page, and clearing your browser's cache to see if any of those steps solve the problem.

Same issue here, code just doesn't work.

$(document).ready(function() {


$('form').submit( function(evt){
  evt.preventDefault();

  var $searchTerm = $('#search');

    // the AJAX part
    var flickerAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
    var animal = $searchTerm.val();
    var flickrOptions = {
      tags: animal,
      format: "json"
    };
    function displayPhotos(data) {
      var 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>';
      $('#photos').html(photoHTML);
    }
    $.getJSON(flickerAPI, flickrOptions, displayPhotos);

  }); // end click

}); // end ready