Hello,
I m trying to access some json data, to log it but it doesn t work no matter what, I tried several URL’s even from wikipedia’s examples and no result, nothing happens. I tested my code on submit, it gets the query but when it tries to grab json data it gets stuck there. This is my code so far:
$(document).ready(function(){
$("#form").submit(function(){
var query = $("#query").val();
var url = 'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + query+ '&format=json&callback=?';
$.getJSON(url, function(json){
console.log(json);
});
});
});
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="articles">
<div class="random">
<a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Click here for a random article</a>
</div>
<form id="form" >
<input type="search" id="query">
<div class="close"></div>
</form>
<p>click icon to search</p>
</div>
</body>
</html>