Hey guys!
Quote generator:
- Already built all the html structure
️
- CSS working correctly
️
- Used AJAX to import an array with the quote details
️
-Make my button change the quote with a new one ever time its clicked
Heres my link:
See the Pen Quotes Generator by Roberto (@luisvzz) on CodePen.
Ive been trying to make that button work but i don’t have an idea of how to make it trigger my ajax post request again. Can someone provide guidance on using deferred callbacks on page load and click actions?
Thanks a lot!!
UPDATE:
The final lines of code that solved my issue were:
$('.btn-quote').on('click', function(e){ callQuotes().done(handleQuotes).fail(errorQuotes) } )
Tip:
I was writing:
$('.btn-quote').on('click', callQuotes());
And if you use a function as a callback and set ( ) at the end, that triggers it immediately causing an error. The correct way to do this is writing:
$('.btn-quote').on('click', callQuote)
Thanks for all your help guys!