Got stuck while doing the "Build a Random Quote Machine" task


I’m doing the “Build a Random Quote Machine” task. I use a as my editor.

I’m trying to retrieve data from using jQuery getJSON() method.

But the following error happenes: XMLHttpRequest cannot load No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘’ is therefore not allowed access.

Could you help please. Thanks in advance.

1 Like

Use this better
and the query should have jsonp=?

@tukhtarov do a quick Google search on something called “CORS”, it will explain your issue and solutions to it. For solution think JsonP…

1 Like

After a lot of searching I figured out that I have to find APIs that offer either JsonP or CORS support. Am I thinking in the right way?

You’re almost there already, you posted that you are already using jQuery getJSON() so to get around the CORS issue just use getJSON() in JSONP mode. It involves adding a callack function.

1 Like

I tried to do this:

$.getJSON( "",
function(json) { console.log(json); }

And I faced an “Uncaught SyntaxError: Unexpected identifier” error.

My query:

1 Like

I see now my mistake. I made format=json when I should make format=jsonp.

Great thanks, guys!

I appreciate your help so much!

There is also some ninjutsu:

And I did used exactly that quote source.


I tried to check my code today. It doesn’t work again.

I see the following in the console:

Mixed Content: The page at ‘’ was loaded over HTTPS, but requested an insecure script ‘’. This request has been blocked; the content must be served over HTTPS.

It appears that the error message in console is telling you that codepen is served as secure https and that forismatic is being served as unsecure http content. Mixed Content is described by MDN.

Try changing your quote server to something served securely like theysaidso.