Problem with "Build a Random Quote Machine" project

Problem with "Build a Random Quote Machine" project
0

#1

Hi, guys. I’m need your help, because I stacked with my “Build a Random Quote Machine” project for a few days. I rewrote code so many times, and try some different APIs, but code still doesn’t work properly. Help me, please. Here’s the code:
$(".btn-new").click(function(){
$.getJSON(“https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=parseQuote”, function parseQuote(quoteObj) {
$("#quote").html(quoteObj.quoteText);
$("#author").html(quoteObj.quoteAuthor);
});
});
Project on Codepen:
https://codepen.io/yur375/pen/gRWVpj


#2

Hi,

I had the same problem as you.

try to incorporate this line of code for your api request

https://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&jsonp=?&lang=en

this should get you going.

now you need to incorporate the the twitter button at least for completing the user stories


#3

Hi there!

It looks like you have one JSON object you’re trying to grab information from.

The .getJSON method’s callback function is an anonymous function (so get rid of the parseQuote name)

source: http://api.jquery.com/jquery.getjson/

The .html() jQuery method accepts either no arguments, or a function. So I would look into that as well.

source: http://api.jquery.com/html/

It looks like you’re really close though! Best of luck.


#4

Hi! And thank you very much, it’s worked. I spent so many time trying to fix it. And your advice was very helpful. Thanks a lot.:slightly_smiling_face:


#5

Hi. Thank you for a useful links, I’ll read this all to better understand the ajax.