getJSON on codepen doesn seem to work

getJSON on codepen doesn seem to work
0.0 0

#1

Hi everyone, i just cant seem to get my code to work in codepen.

I am trying getJSON and it doesnt work, i even copied the code from one challenges over to codepen and it doesnt work.
I actually copied the cats image challenge that works in the IDE part of the challenge, but it doesnt work in codepen

This is the script part:

  $(document).ready(function() {

    $("#getMessage").on("click", function(){
      // Only change code below this line.
      $.getJSON("https://www.freecodecamp.org/json/cats.json", function(json) {
  $(".message").html(JSON.stringify(json));
});
    });

  });

#2

Did you add the jQuery library to your pen’s JS settings?


#3

Also, because you are trying to access a file not on the same domain as codepen.io, so you you need to use JSONP method using $.ajax function or prefix your url with a proxy such as https://cors-anywhere.herokuapp.com/.