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

Treehouse Moderator 17,951 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){

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

    // the AJAX part
    var flickerAPI = "";
    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="' + + '" class="image">';
        photoHTML += '<img src="' + + '"></a></li>';
      }); // end each
      photoHTML += '</ul>';
    $.getJSON(flickerAPI, flickrOptions, displayPhotos);

  }); // end click

}); // end ready