I am using this code on codepen but I am not getting any response from api-call. But when I use same url in browser it shows response. Please help!
$(document).ready(function(){
$("#button1").on(“click”,function(){
$.getJSON(“https://api.forismatic.com/api/jsonp/”, function(json) {
$(".message").html(JSON.stringify(json));
});
});
});
I’m still figuring this out myself, but it appears that forismatic doesn’t accept https and adding some more detail in the api call gave a good result.
$.getJSON("http://api.forismatic.com/api/1.0/?" +
"method=getQuote&lang=en&format=jsonp" +
"&jsonp=?", function(json) {
$(".message").html("\"" + json.quoteText + "\" - <i>"
+ json.quoteAuthor + "</i>");
});