admin管理员组文章数量:1230190
Here I am fetching the data from Wikipedia using following code. but it is not working for me.
var playListURL = '.php?format=json&action=query&titles=India&prop=revisions&rvprop=content&callback=?';
$.getJSON(playListURL ,function(data) {
$.each(data.pages, function(i, item) {
alert(i);
});
});
DEMO LINK :- /
Here I am fetching the data from Wikipedia using following code. but it is not working for me.
var playListURL = 'http://en.wikipedia.org/w/api.php?format=json&action=query&titles=India&prop=revisions&rvprop=content&callback=?';
$.getJSON(playListURL ,function(data) {
$.each(data.pages, function(i, item) {
alert(i);
});
});
DEMO LINK :- http://jsfiddle.net/rushijogle/dyeqy/
Share Improve this question edited Sep 19, 2014 at 17:30 MrLore 3,7802 gold badges29 silver badges37 bronze badges asked May 24, 2013 at 12:52 Rushikesh jogleRushikesh jogle 5912 gold badges9 silver badges29 bronze badges 1- check my answer you will get the proper result by that. – user2334807 Commented May 24, 2013 at 13:12
3 Answers
Reset to default 6Use the following code to get the data:
$.getJSON(playListURL ,function(data) {
$.each(data.query.pages, function(i, item) {
alert(item.title);
});
});
Demo is at http://jsfiddle.net/dyeqy/3/
var playListURL = 'http://en.wikipedia.org/w/api.php?format=json&action=query&titles=India&prop=revisions&rvprop=content&callback=?';
$.getJSON(playListURL ,function(data) {
var hash = data
var page_value = ""
$.each(data["query"]["pages"],function(k,v){
alert(k)
$.each(v,function(key,val){
alert(key)
});
});
});
Like this you can take the revisions values also.
It should be data.query.pages
instead of data.pages
Working Fiddle
本文标签: javascriptHow to retrieve data from Wikipedia API using JSONStack Overflow
版权声明:本文标题:javascript - How to retrieve data from Wikipedia API using JSON? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739392469a2161232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论