Wikipedia:WikiProject User scripts/Guide/Ajax: Difference between revisions

Content deleted Content added
Using module mediawiki.api: Simplification: var api = new mw.Api();\napi.get(...) ---> (new mw.Api()).get(...)
Line 94:
<source lang="javascript">
// Edit page (must be done through POST)
// the line "text: info.text," will cause the call to replace entire page content with supplied data.
// alternatively, one can append or prepend the data to the page, by using
// "appendtext: info.text," or "prependtext: info.text," instead.
when using "appendtext", it is possible to append the text to s specific section,
// by setting the optional field "section".
function editPage( info ) {
$.ajax({
Line 103 ⟶ 108:
action: 'edit',
title: info.title,
text: info.text, // will replace entire page content
summary: info.summary,
token: mw.user.tokens.get( 'editToken' )