Manual talk:Ajax
Add topicCallback function?
[edit]Hello!
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! -- 87.179.94.82 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. 108.6.239.14 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':
$.ajax({
type: "GET",
url: mw.util.wikiScript(),
data: {
action:'ajax',
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_
alert(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)
jsonty
[edit]'//www.mediawiki.org/w/api.php?format=jsonty&action=query&meta=siteinfo&siprop=general&callback=?',
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. 194.207.86.26 11:48, 31 July 2019 (UTC)