Stuck with Wikipedia Viewer

Stuck with Wikipedia Viewer
0

#1

Hi everyone!
I´m struggling with the Wikipedia viewer project for some time, have searched and tried various modifications, but nothing helped. Can you help me please?
(Please ignore the missing css - I´m always doing the css as the last thing, after the whole thing works. :wink: )

Here is the link to my codepen: https://codepen.io/mmajam/pen/JOorOo?editors=1011

Another question is regarding the "$(document).ready(function() " - if I put it there (wrap all my JS code into this function), the page doesn´t load at all. Why?


#2

There’s this warning:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://en.wikipedia.org/w/api.php?action=opensearch&search=magic&format=json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Luckily for the Wikipedia API, the fix is as easy as adding origin=* in the URL parameters.

You might have a syntax error. The last brace should be followed by a closing parenthesis and a semicolon.

$(document).ready(function() {
  // ...
});

Off-topic, but you should load bootstrap.js after you’ve loaded jquery.


#3

Thank you very much!
I fixed the origin and also the bootstrap x jquery (thanks also for this!), but it still doesn´t work. :frowning: What´s wrong now?

(Please where can I see the details about the problem (the warning which you copied here?)


#4

What isn’t working? You should empty the result list before making a new JSON request. You can call $('#listOfResults').empty()

You can see warnings and error messages in the browser console. You can find it when you hit F12 on your keyboard (same for chrome too I believe).


#5

Whooooo!!! :smiley: :smiley: :smiley: Thank you very much! :wink: You´re great!!! :wink: