$.getJSON not working: PLEASE HELP - Random Quote Machine

Greetings everyone,
I am trying to return a random quote with .getJSON but cannot get it to work.
Here’s my test pen.

  • The code I am using is a straight copy of the tutorial
  • I have prepended the CORS proxy (https://cors-everywhere.herokuapp.com/) to the url because the quotes site is http only.
  • I have jQuery included
    I am tearing my hair out. Please can you look and see. Any help much appreciated. I am a newbie, hope it isn’t something blindingly obvious.
    Cheers, Rainer

please change http to https in url
CodePen allow us to call http request only with https

Ah thank you. I have tried so many things and lost myself.
I appreciate i have a CORS issue. To fix that I have prepended a CORS proxy to the request url.
It’s back there now but still no luck.

Thanks for that. It doesn’t address my problem though - the getJSON call was failing and I didn’t ever get inside the callback function. I tested that with console.log entries before the .getJSON() call and inside the callback.

Anyway, I have now changed the quote generator url back to https://random-quote-generator.herokuapp.com/api/quotes/ and that now works for me (it returns a list of quotes so the .forEach() loop is relevant.

Just read that this generator can return a single random quote using this url: https://random-quote-generator.herokuapp.com/api/quotes/random. That keeps the client code simpler and I shall use dot operator notation to dig out the properties as you suggested in the other topic.
Thanks again.
Cheers, Rainer

is works for me , i made some changes but work good :slight_smile:

changes :

  1. you have too mach


  1. this row


put it after this row

html += "</div><br>";

good luck :wink:

Thank you for your help. I think you edited the pen while I was busy working with it. I do have it working now, using an https quote generator: https://random-quote-generator.herokuapp.com/api/quotes/random.