Help with Wikipedia API (Getting Header related Error)

Here is my code pen:

so this is the error I am getting consitently,
Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘’ is therefore not allowed access
All im trying to do for now is get the information from the url on the main page and log it to my console. Apparently i need some sort of header to get access but no matter what I put it doesn’t seem to work. Any ideas on how to fix this?

Add “” before the wikipedia url

hmm maybe not I just tried it on yours, that’s all I added to mine and it fixed the error

yeah that was one of the first things i tried lol, any idea on what the header is supposed to look like?

So i fixed it by changing my dataType from json to jsonp, for some reason that resolves it

I’m using “$.get” over “$.ajax” and haven’t added and headers to my call. I thought get was just shorthand for $.ajax but they seem to work differently so I’m not too sure. Main thing is you sorted it so well done haha

I believe you are right about that, if your talking about JSON.get method. Weird you didn’t need any headers, on their documentation wikimedia says you do lol.

just $.get, maybe it sorts this out for you automatically. They don’t even mention them in the docs for them