开发者

Display data from MediaWiki API request

开发者 https://www.devze.com 2023-03-22 20:27 出处:网络
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()

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

精彩评论

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