Hey,
I’m fighting ( ) with Wikipidia Viewer and I really don’t understand why my request doesn’t work, i’m really confused :
$(document).ready(function(){
$('form').submit(function() {
var keyWord = $("#input-search").val();
console.log(keyWord);
$.ajax( {
method: 'GET',
url: "https://en.wikipedia.org/w/api.php",
dataType : 'jsonp',
headers : { 'Api-User-Agent': 'Example/1.0' },
data: {
action: "opensearch",
format: "json",
origin: "*",
search: keyWord,
formatversion: "2"
},
success: function(data) {
console.log("success");
console.log(data);
},
error: function(response) {
console.log("error");
console.log(response);
}
});
});
});
I have this message in console :
You can check my project here : Api Viewer codepen
Thank you for your help,
Alexandre