Difference between revisions of "AJAX"
(→MediaWiki Ajax: sajax_do_call) |
(See also Extension talk:SimpleForms.php) |
||
Line 17: | Line 17: | ||
*The callable functions listed in ''$wgAjaxExportList'' are just any global PHP functions | *The callable functions listed in ''$wgAjaxExportList'' are just any global PHP functions | ||
+ | *See also [[Extension talk:SimpleForms.php]] | ||
== Popular Ajax Frameworks == | == Popular Ajax Frameworks == |
Revision as of 10:33, 3 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).
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