Hello everyone,
I’m currently working to finish the Front-End intermediate level project “Build a Wikipedia Viewer”. I have faced a problem, which I am trying to find a solution for days. That’s why I am asking your help.
Here it is:
When the user searches for a specific term, the server retrieves information from the following wikipedia API query:
“https://en.wikipedia.org/w/api.php?action=opensearch&format=json&redirects=return&search=” + term
The javascript code snippet is the following:
function retrieve(keyword)
{
var JSONSite = "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&redirects=return&search=";
JSONSite += keyword;
alert("This is executed normally.");
$.getJSON("https://en.wikipedia.org/w/api.php?action=opensearch&format=json&redirects=return&search=term", function (data)
{
alert("This is not executed.");
});
So, the problem is that the code inside the .getJSON function is not executing. What’s wrong with the code? Am I missing something?