I was trying to use and execute the “Get JSON with the jQuery getJSON Method” lesson´s code in codepen (of course placing the code blocks in their respective categories, HTML, CSS and javascript) to see if it works, but it doesn´t :(… it just shows me the title, shadowed text and button, but the button does nothing. Please help…
Here´s the code:
<script>
$(document).ready(function() {
$("#getMessage").on("click", function(){
// Only change code below this line.
$.getJSON("/json/cats.json", function(json) {
$(".message").html(JSON.stringify(json));
});
// Only change code above this line.
});
});
</script>
<div class="container-fluid">
<div class = "row text-center">
<h2>Cat Photo Finder</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well message">
The message will go here
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>