Hi there!
I’m having an issue with the Wikipedia Viewer challenge, namely getting hold of the JSON for the search results.
I’ve tried using the $.ajax and $.getJSON functions, and neither is working for me.
$(“document”).ready(function(){
//Submit button action
$(“#submit-btn”).on(“click”, function() {
var input = $(“#text-search”).val();
var searchURL = “https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exsentences=1&generator=search&gsrsearch=“+input+”&gsrlimit=10&callback=?”;/*
//Ajax attempt
$.ajax({
type: “GET”,
url: searchURL,
dataType: “json”,
success: function (data) {
console.log(data);
},
error: function(errorMsg) {
console.log(“Error”);
}
});
*///getJson attempt
$.getJSON(searchURL, function (data) {
console.log(data);
});});
});
The URL I generate works when I test it in my browser, but in Codepen the following is returned in the console:
Object {
continue: Object {
continue:“||”,
excontinue: 1
},
query: Object {
pages: Object {}
}
}
Does anyone know why I’m not getting the proper response in codepen? I thought I’d worked around the json/jsonp problem, but clearly there’s still some issue.