I try to get articles from Wikipedia using $.ajax method, but I can't figure out what's wrong with my request... When I'm proceeding I'm getting "MIME type ('text/html') is not executable" error. I put my code below:
$(document).ready(function(){
$('#btn').click(function() {
var text = $('input').val();
$.ajax({
url: "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch="+text,
dataType: 'jsonp',
success: function (response){
var articles = response.query.search;
for (var i = 0; i < articles; i++){
var article = articles[i];
var title = article.title;
var snippet = article.snippet;
var url = "https://en.wikipedia.org/wiki/" + title;
$('#display-result').append('<p>'+'<a href="'+url+'">'+title+'</a>'+'</p>');
}
}
});
});
});
I have to use JSONP data type because of Wikipedia rules, but I think that's why I can't get response. Maybe something wrong with my code...
Will be glad for your help!