Wikipedia Viewer not working

Wikipedia Viewer not working
0

#1

I’m having trouble getting data from my getJSON call on my Wikipedia viewer. The link takes me to the data I want when I paste it in a ne window, if I mess with the link I get the fail alert, but otherwise nothing is showing up in the console whether I try to log the data or just a word. Can anyone help? This is what I have:

$(document).ready(function() {
$(“form”).submit(function() {
var input = $("#wikisearch").val();
var link = “https://en.wikipedia.org/w/api.php?action=opensearch&format=json&origin=*&search="+input+"&limit=5&callback=%3F”;
$.getJSON(link, function(data) {
$.fail(alert(“Try again”));
console.log(data);
});


#2

You need to use jsonp, so use an ajax request instead of getJSON

I don’t know enough to explain it properly, but hopefully this link helps!


#3

Thanks, I actually got it working using getJSON and an origin parameter. thanks though!