MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 16: | Line 16: | ||
dataType: 'json', | dataType: 'json', | ||
success: function(data) { | success: function(data) { | ||
console.log('API parse response:', data); // <-- Debug output here | |||
if (data.parse && data.parse.text) { | if (data.parse && data.parse.text) { | ||
$('#categorytree-content').html(data.parse.text['*']); | $('#categorytree-content').html(data.parse.text['*']); | ||
Revision as of 17:34, 3 July 2025
$(function () {
$('#p-navigation').append(`
<div id="p-custom-categorytree" style="padding:10px; border:1px solid #ccc; margin-top:10px;">
<h3>Categories</h3>
<div id="categorytree-content">Loading categories...</div>
</div>
`);
$.ajax({
url: mw.util.getUrl('api.php', {action:'query'}).replace('index.php', 'api.php'),
data: {
action: 'parse',
page: 'SidebarMenu',
format: 'json'
},
dataType: 'json',
success: function(data) {
console.log('API parse response:', data); // <-- Debug output here
if (data.parse && data.parse.text) {
$('#categorytree-content').html(data.parse.text['*']);
} else {
$('#categorytree-content').html('Failed to load categories.');
}
},
error: function() {
$('#categorytree-content').html('Error loading categories.');
}
});
});