Wikipedia:WikiProject User scripts/Guide/Ajax: Difference between revisions
Content deleted Content added
→Edit a page and other common actions: XHR.send requires parameters, should be null if there are none |
→Edit a page and other common actions: bugfix, wgScriptPath instead of hardcoded path |
||
Line 69:
// fetch token
var api = sajax_init_object();
api.open('GET', wgServer + wgScriptPath + '
api.onreadystatechange = extract_token;
api.send(null);
Line 86:
// edit page (must be done through POST)
function
var parameters = 'action=edit&title=User:Pathoschild/Sandbox&text=AJAX_test!&token=' + encodeURIComponent(_token);
api.open('POST', wgServer + wgScriptPath + '
api.onreadystatechange = alert_result;
api.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
Line 114:
function edit_page(_token) {
var parameters = 'action=edit&title=User:Pathoschild/Sandbox&text=AJAX_test!&token=' + encodeURIComponent(_token);
ajax_post(wgServer + wgScriptPath + '
}
function alert_result(_api) {
|