I'm trying to retrieve the title's categories from JSON data.
For example: https://fr.wikipedia.org/w/api.php?action=query&titles=Albert%20Einstein&prop=categories
I tried something like this:
var requestOnURL = "https://fr.wikipedia.org/w/api.php?format=json&action=query&titles=Albert%20Einstein&prop=categories&callback=?";
$.getJSON(requestOnURL ,function(data) {
$.each(data.query.pages, function(i, item) {
alert(item.title);
//alert(item.categories.title);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
If I do an alert for the title it works, but I don't know how to show the categories, still searching.