Manual talk:Ajax

Jump to navigation Jump to search

Callback function?[edit]


Can someone please explain the thing with the "callback function" in a bit more detail? I'd love to call "sortables_init();" to keep my table sortable after I changed their content with "sajax_do_call"...

Thanks in advance! -- 22:25, 1 August 2008 (UTC)

registering php function called via ajax[edit]

For version 1.12 (at least) stuff below must be put in some file that is called by chain of "require_once" statements, starting in LocalSettings.php

global $wgAjaxExportList;
$wgAjaxExportList[] = 'wfYourFunction';
function wfYourFunction(){};

server ajax handler won't find wfYourFunction if it is registered from file referred to via $wgAutoloadClasses.

So, What Now?[edit]

Now that sajax_do_call and action=ajax are deprecated, what are we supposed to use? I tried using jQuery.ajax() to invoke a php file, but the invoked file does not get run in the MediaWiki context and can't use the MediaWiki parser, classes, etc. Unless there's a trick to this that I am missing, I'm jut not sure what to do. This manual page is no help at all; it only has examples calling the API, which may not even be available. 17:13, 14 July 2012 (UTC)

Thast right sajax_do_call is deprecated now вut action=ajax is not. As before you have to register your ext. function in $wgAjaxExportList array:
$wgAjaxExportList[] = 'extFunction';
And then call it indirectly by 'action=ajax':
        type: "GET",
        url: mw.util.wikiScript(),
        data: {
            rs:'extFunction', // your function
            rsargs:[arg1,arg2,arg3] // will be passed as arguments to your function: extFunction (arg1, arg2, arg3)
        dataType: 'html',
        success: function(result){ // the returned value is passed back as a _result_

--Solon (talk) 12:15, 31 July 2012 (UTC)

And for 1.17 Mediawiki? Do you know how to call it? The wikiScript function is not available in 1.17 or previous versions of Mediawiki. Thanks! --Fladei (talk) 19:11, 1 November 2012 (UTC)



Can you provide more information about the jsonty format specifier used in one of the examples. It seems to be TinY JSON but there's not much information. 11:48, 31 July 2019 (UTC)