在mediawiki中更改jQuery的异步选项

时间:2016-01-15 08:08:09

标签: jquery mediawiki

我有一个jQuery: $('#gather-facts').html('<script type="text/javascript">function gatherFacts() { var r = new XMLHttpRequest(); r.open("GET", "https://<server>/apps/merge?host=" + (document.title).slice(18,-9), false); r.send(); }; window.onload = gatherFacts;</script>');'); 在我的MediaWiki:Common.js中工作正常,除了我需要以同步模式运行脚本。

jQuery有一个异步选项,但我似乎无法弄清楚如何将它添加到上面。

目前正在使用MediaWiki 1.25.2

1 个答案:

答案 0 :(得分:0)

好的,所以代码是

$('#gather-facts').html('<script type="text/javascript">function gatherFacts() { var r = new XMLHttpRequest(); r.open("GET", "https://<server>/apps/merge?host=" + (document.title).slice(18,-9), false); r.send(); }; window.onload = gatherFacts;</script>');');`

假设原点与您所在的页面相同,则需要使用

$(function() {
  $('#gather-facts').load("/apps/merge?host=" + 
    document.title.slice(18,-9));
});