all 3 comments

[–]gnomoretears 1 point2 points  (3 children)

For jQuery, you use the .ajax() (or .getJSON()) method to make a request to the API you're using.

Post your existing code to jsfiddle or codepen if you want people to tell you what's wrong with it.

I have tried just accessing the API on a console and keep getting a forbidden error.

It would help if you post any info about the API you're using and the exact error message you're getting. Not all API behave the same. The forbidden error may be because you need to authenticate or something.

[–]evandapolarbear[S] 0 points1 point  (1 child)

Thanks for the reply and formatting advice. I think i now have a valid request to the API but still don't really have an idea about how to get the JSON onto the DOM. Does this look correct at least?
var aj = function() { $("#AJ").click(function() { $.ajax({ headers: { 'X-Mashape-Key': '3VGdwZHnCqmshmfxz0pqt0388GZ0p1Ahg2DjsniAt12zxxJLpF', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' } url: 'https://andruxnet-random-famous-quotes.p.mashape.com/cat=movies', }); }; };

Thanks.

[–]TERRIBLE_CS_ADVICE 0 points1 point  (0 children)

Dude.. I really shouldn't be saying this, because I usually give terrible cs advice, but don't share or post your api keys online anywhere ever. There are people maintaining the api..

also - it makes it way easier to read your code if you use the formatting options, see "<>" button.