Manual:Ajax

MediaWiki offers an AJAX interface for use by extensions. AJAX is a term for using JavaScript to load parts of a page on demand. It can be used as follows:


 * set  in LocalSettings.php, it is set to true by default in MediaWiki 1.17 & above (note that if your extension requires Ajax, make it check if $wgUseAjax is true, and if not, fail)
 * MediaWiki 1.16 is shipped with jQuery version 1.3.2, accordingly there is no need to load any separate library for Ajax

Examples
Some extensions that use MediaWiki's Ajax interface can be found in Category:Ajax extensions. The complete documentation for JQuery's ajax method is here. Here's a simple example:

Add to your resource file
Below is an example call to the login API by posting the username & password

The function "mw.util.wikiScript" is available since 1.18 onwards.

Problems

 * A script cannot retrieve data from a wiki that is hosted on a different domain. (e.g. one cannot retrieve data from http://en.wikipedia.org/wiki/ to http://example.org/wiki/.) This is due to the same origin policy. However, just sending data via GET or POST is possible through some hacks (e.g. submitting a hidden form whose target URL that refers to the target wiki).