Random quote generator project!

Hello, i am building my first project but i am stuck at implementing the API with jQuery, i am trying to do it step by step like the lessons but it doesn’t works, even showing the content with .stringify! Can you give me some tips?

Regards :slight_smile: !

Could you post a link to your project?
It’s hard to give any kind of useful advice based on your description alone.

https://codepen.io/Stivi7/pen/qXRReW?editors=1010 here is my code, i have seen different references and tutorials but still doesnt work, it is driving me crazy!

thanks in advance :slight_smile:

You forgot to import jQuery.
If you haven’t used codepen before, just click on the gear next to the Javascript field, and use quick-add to select it.
Also, depending on whether you’re using https everywhere or not, you might have a problem calling an http link. If that’s the case, simply change the ajax request link from http to https.

I hope that helps!

1 Like

I imported jQuery now but still nothing :confused: where can i change the ajax request link?

At $getJson.
Try:

$.getJSON(“https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=”, function(data){
$(“.message”).html(data[0].content + " - " + data[0].title)

instead of:

$.getJSON(“http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=”, function(data){
$(“.message”).html(data[0].content + " - " + data[0].title)

It worked for me after importing jQuery, and changing that.

thanks man, i love you :smiley: such a great help :slight_smile:

No problem!
Have fun coding!

1 Like

I prefer that method rather than using ajax to view APIs.