ran91
December 16, 2016, 5:37pm
1
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/>‐ " + response.quoteAuthor + " ‐</p>");
}
});
}
$(document).ready(function() {
randomQuote();
$("button").click(function(){
randomQuote();
});
});
vdineva
December 17, 2016, 12:42am
2
@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 .
ran91
December 17, 2016, 5:17am
5
nitdutt
December 17, 2016, 6:19am
6
@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)
nitdutt
December 17, 2016, 6:20am
7
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”.
ran91
December 17, 2016, 8:51am
8
thank u …Finally it has started to work and I have finished my project
1 Like