I am trying to create Wikipedia search page with Wikipedia API. When I type the link I created i successfully see the json file on my browser. But when I try to get that json with jQuery.ajax() method it fails. I made research and found that same-origin policy causes that problem since Wikipedia link has HTTP but I am making https request. I already tried dataType: "jsonp" solution. Didn't work for me. What should I do in order to use my Wikipedia json link? I am a beginner and not native English speaker btw. Please consider that in your responses.
Here's my codepend project: https://codepen.io/emred2700/details/vjeWRz/
Here's the code:
$("#sbmt").on("click", function(){
var $searchWord = $(".s-bar").val();
var url = encodeURI($searchWord);
var wikiUrl = 'http://en.wikipedia.org/w/api.php?action=opensearch&search=' + url + '&format=json&callback=wikiCallback';
$.ajax({
url: wikiUrl,
dataType: "jsonP",
success: function(response){
console.log(response[1]);
}
});
});
Here's the error on my console:
jquery.min.js:2 Mixed Content: The page at 'https://codepen.io/emred2700/pen/vjeWRz?editors=1010' was loaded over HTTPS, but requested an insecure script 'http://en.wikipedia.org/w/api.php?action=opensearch&search=asda&format=json&callback=wikiCallback&callback=jQuery33108891831563559673_1525711553641&_=1525711553642'. This request has been blocked; the content must be served over HTTPS.