Question

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=content&titles="+title+"&format=json&callback=?",
        function(data){
            data.text();
        });
    });
Was it helpful?

Solution

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"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top