Hi everyone. I’m almost done with my Random quote Machine. I was having overflowing issues that I decided to solve by only letting quotes shorter than 130 characters into my #quote div.
Here’s what I did to the getQuote function:
function getQuote() {
$.getJSON(url, function(data) {
if ((data.quoteText).length < 130){
$("#quote").html(data.quoteText);
$("#author").html(data.quoteAuthor);
tweetQuote();
} else {
getQuote();
}
});
}
The problem is that if the quote is longer than 130 characters, it doesn’t print anything to the html, so the user has to click again. I added a call to the getQuote function in the else statement which solves the problem only if you don’t get two consecutive long quotes. It should keep getting quotes until it gets a short one.
Can anyone help me fix this?
Here’s my full code in case you need to see it:
https://virginiabalseiro.github.io/WiseMonkey/
And here’s the live version:
https://virginiabalseiro.github.io/WiseMonkey/5
Thanks!!!