Help with "Build a wikipedia viewer"

My pen: https://codepen.io/Azrah/pen/EvYRdo
I don’t know where to go from there, I’m using ajax to get the json, since I want to put the user agent header at the same time, and i’m using the opensearch API to get an array, but when I try to acess it using data[1] or similiar and test using console or an jQuery to an h1 or p or div, nothing happens.
I’m using opensearch because it returns an simple array with all I need, the titles, links and extracts. But I need to be able to acess it’s contents, and dunno how.

Try changing .success to .done as per jquery docs.

Also for dataType:'json' to work you need CORS, which is not possible, afaik, with Wikipedia, so change it to dataType:'jsonp', then you’ll get an array with results. You can read some more on the subject.

Edit:
Also you can use a ‘middleman’ proxy server like this to overcome CORS restrictions.

1 Like

There shouldn’t be any CORS restrictions when using https://... wikipedia...&origin=* on https://...codepen...

You are right.
More info on stackoverflow for those interested.