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

Content deleted Content added
m (rv test) Undid revision 289084094 by 125.164.222.11 (talk)
added brackets to if statements
Line 40:
function show_result(_api) {
if(_api.readyState==4) {
if(_api.status==200) {
alert('The remote page contains:\n' + _api.responseText);
} else {
alert('The query returned an error.');
}
}
}
Line 52 ⟶ 53:
ajax_get('http://example.com', show_result);
function show_result(_api) {
if(_api.ajax_success) {
alert('The remote page contains:\n' + _api.responseText);
} else {
alert('An error occurred.');
}
}
</source>
Line 117 ⟶ 119:
}
function alert_result(_api) {
if(_api.ajax_success) {
alert('Page edited!');
} else {
alert('An error occurred.');
}
}
</source>