I need help with Random Quote Machine

I need help with Random Quote Machine
0

#1
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.


#2

Are you doing this on Codepen? Could we see the rest of your code? The main issue is going to be how you’re going to get the data. Are the quotes you want to get using ajax stored in a javascript object somewhere? Is there a particular site that you want to get the quotes from?


#3

Do you have the code using JQuery and AJAX?


#4

Nope. I built mine with an array…a long time ago, too.