MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
$.ajax({ | $(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.wikiScript('api'), // <-- fixed here | |||
data: { | |||
action: 'parse', | |||
page: 'SidebarMenu', | |||
format: 'json' | |||
}, | |||
dataType: 'json', | |||
success: function(data) { | |||
console.log('API parse response:', data); | |||
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.'); | |||
} | } | ||
} | }); | ||
}); | }); | ||
Revision as of 17:39, 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.wikiScript('api'), // <-- fixed here
data: {
action: 'parse',
page: 'SidebarMenu',
format: 'json'
},
dataType: 'json',
success: function(data) {
console.log('API parse response:', data);
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.');
}
});
});