Random quote generator - why is the load method not working?

Random quote generator - why is the load method not working?
0

#1

Hey guys!!
I am working on the random quote generator project and honestly I’m not really sure what I’m doing with API requests… I’ve been testing and reading but i can’t seem to get any method to display a quote when I click the new quote button. I feel like the load method I attempted should work but can’t figure out why it doesn’t…

Here’s my codepen: http://codepen.io/sdkevorkian/pen/rjYGWa

Now that i’m posting I’m wondering if I should use the getJSOn method (http://www.w3schools.com/jquery/ajax_getjson.asp) , save it in a variable, and then use the variable to display in the html method (http://www.w3schools.com/jquery/jquery_dom_set.asp)?

Thanks to anyone that spent the time reading! hopefully you can help :slight_smile:


#2

It seems that you must use jsonp.

You can’t really save it in a variable anyway, it’s an asynchronous function. you need to do whatever you need with the data in a callback function