I’ve been trying to implement an app that searches for wikipedia articles within a certain category using the wikipedia api. I already have an app that uses the api, but it searches all of wikipedia.
I’ve had a great deal of trouble finding the correct syntax for my project. The api returns the same result, no matter what I search. Thanks so much!
Here’s my code so far:
var url =
"https://en.wikipedia.org/w/api.php?action=query&search=" + "force" +
"&list=categorymembers&cmtitle=Category:Physics&format=json&callback=wikiCallback";
var displayWikiData = function() {
$.ajax({
url: url,
type: "GET",
dataType: "jsonp",
jsonp: "callback",
success: function(res) {
console.log(res);
}
});
}
Here’s what the console logs:
query: {…}
categorymembers: (10) […]
0: Object { pageid: 22939, ns: 0, title: "Physics" }
1: Object { pageid: 24489, ns: 0, title: "Outline of physics" }
2: Object { pageid: 3445246, ns: 0, title: "Glossary of classical physics" }
3: Object { pageid: 1653925, ns: 100, title: "Portal:Physics" }
4: Object { pageid: 50926902, ns: 0, title: "Action angle coordinates" }
5: Object { pageid: 9079863, ns: 0, title: "Aerometer" }
6: Object { pageid: 52657328, ns: 0, title: "Bayesian model of computational anatomy" }
7: Object { pageid: 49342572, ns: 0, title: "Group actions in computational anatomy" }
8: Object { pageid: 50724262, ns: 0, title: "Blasius–Chaplygin formula" }
9: Object { pageid: 33327002, ns: 0, title: "Cabbeling" }
length: 10