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