Ar8nas
June 19, 2017, 1:36pm
#1
Hello,
I am trying to complete “Random quote generator” assignment and I am hit the roadblock.
In project (link below) I using API to get data and simply make it visible. But it is not working… I realizing that I missing something trivial, but I can not find it by myself. Cold someone help me?
https://codepen.io/Ar8nas/pen/JJYZYv
Thanks in advance!
I get the following console error when clicking “Get”
pen.js:6 Mixed Content: The page at ‘https://codepen.io/Ar8nas/pen/JJYZYv ’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=&_=1497879912402 ’. This request has been blocked; the content must be served over HTTPS.
Codepen only supports HTTPS now, so you’ll need to change your Ajax call to have HTTPS instead of HTTP
Ar8nas
June 20, 2017, 1:20pm
#3
Thanks, this was the problem.
To other people who solving the same assignment.
I found 2 API-s (quotesondesign.com and forismatic.com ) which can return random quote. Just pick quotesondesign:
$.getJSON(“http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback= ”, function(a) {
$(“body”).append(a[0].content + "
— " + a[0].title + “
”)
});
and change http to https.
P.S. For reasons I have no qualification to explain, same trick is not working in forismtaic.com