Random quote generator not working for no known reason

Hi campers!

I just spent an entire afternoon trying to figure out what is wrong with my simple code.

I’ve tried the others campers sugesttions related to same probelm but still not working.

Can you take a look at my code and see if you can sopt the problem.

PS. I have tried the crossorigin thing.

Thanks for your answer.

Made the changes suggested but gave this error and still not working.

“Refused to execute script from ‘https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json&jsonp=jQuery321032191368788916086_1515403308438&_=1515403308440’ because its MIME type (‘application/json’) is not executable, and strict MIME type checking is enabled.”

Thanks again!

I changed the Api because i have read that the Api is no longer maintained.

New quote button is working now,

Twitter button opens a new window and does nothing, just a blank page. Any idea on what it could be? Code is ok.

Can you tell if there is any issue with codepen? Because i tested the remove p tag in this website https://ideone.com/fork/62buxj and it works fine. But it keeps adding closing p tag in codepen.
I also used regex to replace single quotes but seems i’m doing it wrong.

For example:

“Every new thing you make will be (should be) the nicest thing you’ve made so far, because you’re learning and getting better with each and every new project.”

it’s transformed to:

“Every new thing you make will be (should be) the nicest thing you’ve made so far, because you’re learning and getting better with each and every new project.</p>”

It also cuts the string when it finds semicolon when posting to twitter.

For example: “The conclusion of design flows naturally from the data; we should not shrink from it; we should embrace it and build on it.”

becomes: "The conclusion of design flows naturally from the data

1 Like

Thanks @camperextraordinaire!

I searched the forum but seems i’m the first having this issue. When transfering the string to the twitter page it cuts it if find semicolon or quote. Any insight on what it might be?

Thanks again for your suport. I’m working on the weather app in the meanwhile.

encodeURIComponent(randomQuote) results in something like this.

"Stop. I’m not going to take any more input until I’ve made something with what I got. "

What worke was this:

window.open(“https://twitter.com/intent/tweet?text=” + $(".quote").text());

@camperextraordinaire

“If everyone likes your design, it&#8217;s banal. Mediocrity shirks offense. Art dares it.”

This is how it looks. Freecodecamp forum converted it back again, lol.

Notice the quote is converted. That’s what happened.

Oh, you right, still have to check that. :frowning:

Using encodeURIComponent on $(“.quote”).text() seems to do the job.

1 Like