Wikipedia viewer problem

what does this mean?

XMLHttpRequest cannot load https://en.wikipedia.org//w/api.php?action=query&format=json&prop=extracts&…entences=1&exlimit=max&exintro=1&explaintext=1&gsrlimit=10&gsrsearch=space. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://s.codepen.io’ is therefore not allowed access.

and now I noticed that if I click that link here I get this result:
{
warnings: {
main: {
*: “Unrecognized parameters: …entences, gsrlimit, gsrsearch.”
}
},
batchcomplete: “”,
limits: {
extracts: 20
}
}

but if I click the same link from the original source in javascript console it works like is should work

Add

&origin=*

at the end of the link.

that worked! thanks, but what does that actually do? It is not used in the example projects code.

From MediaWiki API:

origin
For non-authenticated requests, specify the value *. This will cause the Access-Control-Allow-Origin header to be set

ok. well I just tried using the same url as in the example code and that also didn’t work in my pen without that &origin=*

I think the example is using jsonp not json, could this be why the same url work in the example pen but not in my pen?

You either need to use origin=* or jsonp.

Read what JSONP is: http://stackoverflow.com/questions/3839966/can-anyone-explain-what-jsonp-is-in-layman-terms

I would recommend to use origin=*