These are chat archives for MontCode/GeneralChat

21st
May 2017
David Castner
@davidjcastner
May 21 2017 00:01
I think it would benefit you to look up what a restful api is and how http works. Here are a couple videos to watch: https://www.youtube.com/watch?v=7YcW25PHnAA
Lily Romano
@Lilyheart
May 21 2017 00:25
api/json/etc is one of those things that can be a pain to grasp and it doesn't make sense until all the pieces are together and workin' and your like oooooh!
This webpage my roommate visited has an interesting problem xD Sometimes the ad doesn't load but an empty function "prints" instead.
image.png
Lily Romano
@Lilyheart
May 21 2017 00:30
But the interesting thing is, i get an empty function. He gets an function that is not empty.
image.png
I bet non-IE "completes" the incomplete comment /* but IE/Edge doesn't so shows it literal.
Lucas Morley
@Luc1100
May 21 2017 13:31

http://codepen.io/Luc1100/pen/BRqQXv

Can someone please tell me what I am doing wrong? I literally copied this from a tutorial on youtube and it will still not generate a new quote.

Lily Romano
@Lilyheart
May 21 2017 15:42
A few things off the bat. If you open up the console (Are you using chrome? If so, press ctrl+shift+i and make sure you are looking at the console tab) you will see the first problem is VM740 pen.js:1 Uncaught ReferenceError: $ is not defined at VM740 pen.js:1. $("#id") is a way to select things using jQuery so be sure to include jQuery in the pen's options.
Lucas Morley
@Luc1100
May 21 2017 15:47
Ohhh I'm really stupid, I forgot jQuery had to be added
Thanks @Lilyheart !
MontBot
@MontBot
May 21 2017 15:47
luc1100 sends cookie points to @lilyheart :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @lilyheart |http://www.freecodecamp.com/lilyheart
Lily Romano
@Lilyheart
May 21 2017 15:49

After you fix the jquery issue and click New Quote there is a new error in the console. This one is more tricky. XMLHttpRequest cannot load http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en&_=1495381321698. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.

There is something to read before understanding what is going on. CORS on the mdn. Read and research until this make sense.

Always Always Always look at the console. It will give (usually) some clue as to what is going on. Use the browser (I recommend chrome) console... not codepen's however... as sometimes things don't appear in the codepen console (and you wanna get used to not using codepen anyway).
Lucas Morley
@Luc1100
May 21 2017 17:02
I just used the other quote API, it was more up to date and it didn't give me the No Access header thing
I know I'm being lazy
Lily Romano
@Lilyheart
May 21 2017 17:04
xD Nothing wrong with lazy. Just be sure you understand why. Because, anytime you try to connect a different website this might happen.
Lucas Morley
@Luc1100
May 21 2017 17:06
Reading up on it now, thanks for the help