0

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!

Liam
  • 27,717
  • 28
  • 128
  • 190
DragoRoff
  • 55
  • 4
  • 1
    You know [wikipedia provide an API right](https://stackoverflow.com/questions/7185288/how-to-get-wikipedia-content-using-wikipedias-api)? This is to stop people using bots to crawl them (like your doing) – Liam Oct 31 '17 at 15:38
  • I'm not using bots, I just try to get any response from Wiki and for now I haven't succeed.. – DragoRoff Oct 31 '17 at 16:20

0 Answers0