Wikipedia Viewer CORE Problems

Wikipedia Viewer CORE Problems
0.0 0

#1

So i got some problems with my Wikipedia Viewer.
Link: http://codepen.io/Chepalos/pen/vxYJpK?editors=1111
Every time i search something i get an error message: XMLHttpRequest cannot load https://www.mediawiki.org/w/api.php?&action=opensearch&format=json&search=n. Origin http://s.codepen.io is not allowed by Access-Control-Allow-Origin.
I already figured out that this has something to do with COREs. So my Questions are why i get this messages, how can i fix this and where can i learn more about that topic?


#2

Here is the full explanation. You need to have your string end with &callback=?

url:‘https://en.wikipedia.org/w/api.php?action=opensearch&search=’ + searchTerm + ‘&callback=?’


#4

As already mentioned, you need to add the callback=? parameter.

Besides that, $.get() seemingly requires a dataType parameter. According to the documentation it is optional, but I found that adding it solves the problem. You could of course also use getJSON instead.


#5

Thank you all for your help. It worked