Getting problem in random quote generator

when Iam clicking the button , it is not showing any result.
here is my js code

function randomQuote() {
  $.ajax({
      url: "http://api.forismatic.com/api/1.0/?",
      dataType: "jsonp",
      data: "method=getQuote&format=jsonp&lang=en&jsonp=?",
      success: function( response ) {
        $("#random_quote").html("<p id='random_quote' class='text-center'>" +
          response.quoteText + "<br/>&dash; " + response.quoteAuthor + " &dash;</p>");
        
        
        
        
      }
  });
}

$(document).ready(function() {
  randomQuote();
  $("button").click(function(){
  randomQuote();
});
});

@ran91 please post a link to a codepen with your code and I’ll be glad to help you

@jenovs answered to you 7 hours ago but you never replied to him.

You can find his reply here.

Unless it’s not the same code? But apparently it was working ?

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

The link is …https://codepen.io/ran91/pen/YpJmYM

@ran91 Your code has one problem, you have mixed _ and -. You have defined the id as random_quote but your html is being outputted to random-quote. Also, instead of using $(“button”).click(), give your button a unique id/class (because there are two buttons)

Also, do not use https while using codepen if you are using any url containing http in your code, use http instead. Google “mixed content”.

thank u …Finally it has started to work and I have finished my project

1 Like