Difference between revisions of "AJAX"

From Organic Design wiki
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.
 
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).
 
 
The MediaWiki equivalent of this is a JavaScript function from ''ajax.js'' called ''sajax_do_call'', which is used as follows:
 
<js>
 
sajax_request_type = 'POST' // default is GET
 
sajax_do_call('php-function',[data],document.getElementById('target-id'));
 
</js>
 
 
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''.
 
 
*The callable functions listed in ''$wgAjaxExportList'' are just any global PHP functions
 
*See also [[Extension talk:SimpleForms.php]]
 
  
 
== Popular Ajax Frameworks ==
 
== Popular Ajax Frameworks ==
Line 27: Line 9:
 
*[[w:Ajax (programming)|Wikipedia:Ajax]]
 
*[[w:Ajax (programming)|Wikipedia:Ajax]]
 
*[http://www.w3schools.com/ajax/default.asp W3C Ajax tutorial]
 
*[http://www.w3schools.com/ajax/default.asp W3C Ajax tutorial]
 +
*[[05 October 2007]] ''- news item about OrganicDesign changing to MediaWiki native ajax functionality''
 +
*[[Talk:{{PAGENAME}}]] ''- original conversation about mootools independence''
 
[[Category:glossary]]
 
[[Category:glossary]]

Revision as of 10:44, 5 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.

Popular Ajax Frameworks

See also