I am trying to access Wiki API in Javascript. If I type in URL then get the data, but if I use it in Javascript function then it doesn't work. Here is the url:
I was successful in JQuery, but I want to know how we can extract in Javascript.
Any help will be appreciated.
<div id="getw"></div>
var url = "https://en.wikipedia.org/w/api.php?action=query&format=json&titles=New_York&prop=revisions&rvprop=content&callback=?";
function getText() {
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
var wdata = JSON.parse(request.responseText);
document.getElementById("getw").innerHTML = wdata.query.normalized[0];
}
}
request.send(null);
}