The following simple code isn't working for Wikipedia API. I'm not sure why.
html:
<button id="main" onclick=doThis()>Main</button>
<div id="result">h<div>
Script:
function doThis() {
var wikiUrl = "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json";
$.getJSON(wikiUrl, function(data) {
alert(data);
},
$('#result').html("no")
)}
Output:
the $('#result').html("no")
line gets executed which I believe means that the getJSON didn't return anything.
What's wrong & how do I fix this?