function newQuote() {
$.ajax({
type: "GET",
url: "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
success: function(data) {
//console.log('success', data);
quote = JSON.parse(data);
$('#content').html(quote[0].content);
$('#author').html(quote[0].title);
}
});
}
$(document).ready(function() {
var quote;
newQuote();
$('#getQuote').click(function(event) {
newQuote();
});
});
Random Quote Machine
<div class="row text-center">
<div class="well" id="content">
The quote will go here
</div>
<div id="author">The author will go here </div>
<div class="row text-center">
<button id="getQuote" class="btn btn-primary">Get Quote </button>
</div>
</div>
When I click on my get quote button nothing shows up. I did this project before by copying and pasting an array with a bunch of quotes and randomly selecting one of those, but I want to be able to do this using ajax and jquery.