Display data from MediaWiki API request
I use .getJSON()
to extract information from Wikipedia, using the MediaWiki API. I don't know how to handle the data I get. For example, how can I display the text content? I've tried using .text()
below, but I'm a little clueless.
var title="jQuery";
$.getJSON("http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=cont开发者_StackOverflowent&titles="+title+"&format=json&callback=?",
function(data){
data.text();
});
});
you can use http://api.jquery.com/jQuery.parseJSON/ for parsing the JSON data. But seems your above url will give you incorrect json structure, try use this instead : "http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles="+title+"&format=json"
精彩评论