I am trying to build a simple Random Quote Generator in Codepen as you can see here: http://codepen.io/scabbyjoe/pen/dXQmLw
Relevant code pasted below:
<html>
<head>
</head>
<body>
<h1>Random Quote Machine</h1>
<div class="quote">
</div>
<div class="btn">New Quote</div>
</body>
</html>
$(document).ready(function() {
$(".btn").on("click", function(){
$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en", function(json) {
$(".quote").html(JSON.stringify(json));
});
});
});
I am afraid I must be misunderstanding the getJSON tool as I cannot get any content to load up in my .quote
div.
Can anyone explain why this isn't working?
I am try to follow from this (separate) example which is indeed working:
<script>
$(document).ready(function() {
$("#getMessage").on("click", function(){
$.getJSON("/json/cats.json", function(json) {
$(".message").html(JSON.stringify(json));
});
});
});
</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>