In need of help with my 'new quote' button and my tweet button [Solved]

Hello fellow campers!

So I just started the Intermediate projects and I ran into this problem in my Random Quote Machine (link on Codepen). In short - it doesn’t work.
Whenever I click the ‘new quote’ white button I’m supposed to be calling the function getNewQuote() and therefore changing the content of #quoteText and #quoteAuthor however I seem to be returning the same quote. I’m really lost here so any help would be appreciated.

[FIXED]Also, if you test the ‘tweet’ button you will notice that the predetermined text/quote is ‘served’ as HTML since that is the way I receive it on the API call. Is there any way to format it other than using regular expressions? I put it in #quoteText and #quoteAuthor using the .html() method which takes care of all tags etc. but I’m not quite sure how to make it text-only within the tweet.

Thanks in advance!

Hey, add this line of code directly after your document ready: $.ajaxSetup({ cache: false }); This will make sure that the browser doesn’t fetch a cached result, when you run a ajax/json request.

2 Likes

Yes, thank you it works now!

1 Like

You can extract the text from the html in the quote by replacing

decodeURIComponent($quoteContent)

with

$.parseHTML($quoteContent)[0].innerText

in your call to the twitter API.