Wikipedia:WikiProject User scripts/Guide/Ajax: Difference between revisions
Content deleted Content added
Pathoschild (talk | contribs) m →Code: updated |
Pathoschild (talk | contribs) m tweaks |
||
Line 1:
[[Ajax (programming)|AJAX]] (''asynchronous JavaScript and XML'') is a popular name for a web programming technique that queries the server or fetches content without reloading the entire page.
While programming AJAX can be complex, libraries of functions can make it much easier. MediaWiki's [{{SERVER}}/skins-1.5/common/ajax.js ajax.js] provides a small set of functions by default, and [[m:User:Pathoschild/Scripts/Ajax framework|Pathoschild's AJAX framework]] provides a more comprehensive library of functions. This page will document
==Common problems==
Line 25:
===Fetch page content===
Fetching a page content can
<source lang="javascript">
/************
Line 40:
if(_api.readyState==4) {
if(_api.status==200)
alert('The remote page contains:\n' +
else
alert('The query returned an error.');
Line 52:
function show_result(_api) {
if(_api.success)
alert('The remote page contains:\n' +
else
alert('An error occurred.');
Line 59:
===Edit a page and other common actions===
Scripts can
The code below shows how to edit a page, but it can easily be adapted to other actions by reading the [{{SERVER}}/w/api.php API documentation].
|