Wikipedia Viewer not working

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);
});

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!

1 Like

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

1 Like