开发者

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"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜