Quote machine getJSON won't work on codepen?

Quote machine getJSON won't work on codepen?
0

#1

I don’t get it, it worked just fine with Atom then i transferred it to codepen and none of the JavaScript works. I went to the settings and added jQuery to the javascript but nothing.


If anyone would take a look I would GREATLY appreciate it.


#2

It sort of works for me.

First of all, never use alert for debugging… alert("didnt work") will always run. Now the API call works, but because the request is cached it will simply fetch the same quote over and over again. To prevent this, add this line at the top of your JS: $.ajaxSetup({ cache: false });


#3

It works for me as well…

If you are behind a filter (ex: company network) maybe its your connection.

Do you get results from:

http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=

You should get a JSON as a response (i do!)

Also… i agree with @BenGitter … don’t use “alerts” for debug (i go a bit further and say “don’t use them at all!!”… use the console instead)… it’s a really annoying trend these days, even in PROD sites!!


#4

i was just using alert to see if my on click function was working. on my side nothings working. i switched from jQuery to just getElementById and that got the button working. but then i put the getJSON in and tried to alert(data), nothing. so i just put my alert(“hello world”) in the anonymous function of the getJSON and nothing. i may just go ahead and submit it since you guys said it was working, but it isn’t doing nothing on my end. another issue i had with it was on my compiler the twitter icon and the click button was div’d into a row of two col-xs-6 and floated side by side. this isn’t working on codepen either. Idk, but i appreciate the feedback. this is the first time i have ever had to post to a forum so its so cool to hear back from the community. I suck at debuggin currently. the whole alert(“message”) is the only move i got lol. thanks so much, im going to keep working on it