[SOLVED] Quote generator - Help Please

Hey guys!

Quote generator:

  • Already built all the html structure :heavy_check_mark:
  • CSS working correctly :heavy_check_mark:
  • Used AJAX to import an array with the quote details :heavy_check_mark:

-Make my button change the quote with a new one ever time its clicked :x:

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!

You have a bit of syntax error at the end of your JS (there should be a small red circle on the bottom right of the JS editor).

yeah you are right, i was still trying to make my code work after i posted my question. Thats why there was a syntax error. I managed to fix my problem now. Thanks a lot!