I’m successfully pulling a random quote from an API, but I’m only able to pull one. Clicking the button more than once does nothing.
I’ve searched around, but I can’t find a clear answer. Any idea what’s causing this?
Please excuse the ugliness. I haven’t started styling the app yet.
Update: My request was getting cached (pulling one quote and keeping it). I had to turn off cache for this function. This Stack Overflow question helped clear up the issue. Thanks again for all the helpful answers – this community is awesome
onclick and its callback function are fine, with that in mind, the cause of problem seems to be your API parameters. Apparently, you are receiving the same quote on each request. I’d suggest that you consult with the API document.
Edit: I was wrong on that, as others pointed out the problem was cached request giving you same response.
Most likely the request is cached. You can disable cache if you use jQuery or add a random parameter to your request.
I had the same issue untill I added this code to my pen.
What it does, as fas as I understand - it tells ajax not to cache information it’s got. Hope it helps.
This was my problem. Thanks for the nudge in the right direction!