Difference between revisions of "AJAX"
m (Caretaker: headings) |
(Mootools way) |
||
Line 1: | Line 1: | ||
− | [[ | + | Ajax is Asyncronous Javascript And XML. The main concept is the ''XmlHttpRequest'' (XHR) object which is a standard way of making HTTP requests from within the JavaScript runtime environment. |
− | + | ||
+ | == MediaWiki Ajax == | ||
+ | Currently our Ajax extensions ([[Extension:SimpleForms|SimpleForms]] and [[Extension:Livelets|Livelets]]) use the [http://mootools.net MooTools] JavaScript framework. The most commonly used ajax process is to post a form to the server and have the response directed to the ''innerHTML'' property of an element having a particular ''id'' attribute. The ''mootools'' syntax for achieving this functionality is: | ||
+ | <js> | ||
+ | $('form-id').send({update:$('target-id')}) | ||
+ | </js> | ||
+ | where ''form-id'' specifies the ''id'' attribute of the form whose content we want to send to the server, and ''target-id'' is the ''id'' attribute of the element the servers response should be appear within (usually a ''div'' element). | ||
+ | |||
+ | It says in [[MW:Manual:Parameters to index.php]] regarding ''action=ajax'', that a PHP function in ''AjaxFunctions.php'' will be executed. That module contains ''wfSajaxSearch'' (search for articles of title similar to a search term) and ''wfAjaxWatch'' (watch/unwatch a page). Note that ''$wgUseAjax'' must be set to true and the only callable functions are those in the array ''$wgAjaxExportList'' (which is also modified by the variables ''$wgAjaxSearch'' and ''$wgAjaxWatch''). In addition to ''action=ajax'', there is ''rs'' (the function name, e.g. ''rs=wfSajaxSearch''), ''rsargs[]'' (an array of arguments to the function (e.g., rsargs[]=abcd passes the abcd string to the function). There is a JavaScript function for calling this action in ''ajax.js''. | ||
− | = | + | == Popular Ajax Frameworks == |
+ | *http://mootools.net | ||
+ | *http://www.prototypejs.org | ||
*http://wiki.script.aculo.us/scriptaculous/show/Demos | *http://wiki.script.aculo.us/scriptaculous/show/Demos | ||
+ | |||
+ | == See also == | ||
+ | *[http://www.w3schools.com/ajax/default.asp W3C Ajax tutorial] | ||
+ | [[Category:glossary]] |
Revision as of 10:04, 2 October 2007
Ajax is Asyncronous Javascript And XML. The main concept is the XmlHttpRequest (XHR) object which is a standard way of making HTTP requests from within the JavaScript runtime environment.
MediaWiki Ajax
Currently our Ajax extensions (SimpleForms and Livelets) use the MooTools JavaScript framework. The most commonly used ajax process is to post a form to the server and have the response directed to the innerHTML property of an element having a particular id attribute. The mootools syntax for achieving this functionality is: <js> $('form-id').send({update:$('target-id')}) </js> where form-id specifies the id attribute of the form whose content we want to send to the server, and target-id is the id attribute of the element the servers response should be appear within (usually a div element).
It says in MW:Manual:Parameters to index.php regarding action=ajax, that a PHP function in AjaxFunctions.php will be executed. That module contains wfSajaxSearch (search for articles of title similar to a search term) and wfAjaxWatch (watch/unwatch a page). Note that $wgUseAjax must be set to true and the only callable functions are those in the array $wgAjaxExportList (which is also modified by the variables $wgAjaxSearch and $wgAjaxWatch). In addition to action=ajax, there is rs (the function name, e.g. rs=wfSajaxSearch), rsargs[] (an array of arguments to the function (e.g., rsargs[]=abcd passes the abcd string to the function). There is a JavaScript function for calling this action in ajax.js.