It’s nearly 4am, and I cannot for the life of me get my ajax function to successfully get data from Wikipedia’s API.
$.ajax({
url: 'https://en.wikipedia.org/w/api.php',
type: 'GET',
datatype: 'jsonp',
data: {
action: 'opensearch',
format: 'json',
search: searchTerm,
limit: '10',
callback: '?'
},
xhrFields: {
withCredentials: false
},
success: function(json) {
$('#results').html(searchTerm + ' IT WORKED???');
},
error: function(a, b, c) {
$('#results').html('Search unsuccessful: ' + a + ', ' + b + ', ' + c);
}
});
If anyone can give me a hint as to what I’m doing wrong, I’d really appreciate it!
And here’s a link to the codepen if you wanna fiddle around with it.