Why am I not receiving JSON here?

Why am I not receiving JSON here?


Hi, just working on the Javascript that will give JSON from the wikipedia API. I’m following along the JSON APIs and Ajax tutorial and trying to stringify the JSON for the time being. However, I believe I’m not receiving any because the function isn’t being executed even if I just make it post to the console. I think my link is correct because it yields JSON when I use it in my browser.


Codepen : https://codepen.io/BLBaylis/pen/BdVqbG?editors=1010


If you look at your console (Ctrl + Shft + I on Chrome) you will see the following error:

XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=hi&prop=revisions&rvprop=content&format=json. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://s.codepen.io’ is therefore not allowed access.

Google “JQuery getJSON JSONP” and read through a few of the search results to use JSONP as a workaround.


Ahh I was unaware that the browser console would give different errors to the codepen one. I will search down this path then. Thanks!