Need help with my Random quote machine: no quotes are loaded

Need help with my Random quote machine: no quotes are loaded
0.0 0

#1

$(document).ready(function(){
  getNewQuote();
});

 $("#newQuotebtn").click(function(){
   getNewQuote();
 });

 function getNewQuote(){
   $.ajax({
  type: 'GET',
  dataType: 'json',
   cache: false,
  url: 'https://crossorigin.me/https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?',
  success: function(data){
    $("#quote_body").hide();
    $("#quote_author").hide();

    $("#quote_body").html(data.quoteText + "<br>");
    $("#quote_author").html(data.quoteAuthor);
  }
});   
  }

<html>

<head>
   <meta charset="utf-8">
  <title>Random Quote Machine</title>
   <meta name="description" content="Quote Generator">
  <meta name="author" content="Naziya Kadri">

  <!-- Mobile Specific Metas
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- FONT
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
  <link href='https://fonts.googleapis.com/css?family=Lora:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
  <link href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>

 <style>
   
  </style>
  <body>
    <div>
      <h2 class="text-center">Famous Quotes</h2></div>
    <div class="container-fluid" id="quote_section">
       <div class="row text-center ">
        <div class = "col-xs-12 ">
          <h2 id="quote_body"></h2>
   </div>
  </div>
      <div class="row ">
        <div class="col-xs-12">
          <h3 id="quote_author"></h3>
        </div>
      </div>
      <div>
        <p/>
        <p/>
      </div>
      <div class = "row text-center">
    <div class = "col-xs-12">
      <button id="newQuotebtn" class="btn btn-info ">NEW QUOTE</button> 
    </div>
      </div>
    </div>
  </body>
</html>

why is my code is not loading any quotes.


#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#3

Your url is way off. You can simply use https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp (note the https) and then change your dataType to ‘jsonp’ and add jsonp: ‘jsonp’ to the $.ajax settings.

Lastly, you are currently hiding the quote and author with the following, so you will not see anything even with the correct $.ajax settings.

      $("#quote_body").hide();
      $("#quote_author").hide();

#4

Thanks. It is working now.