Hi Folks --
Appreciate any help with this question -- can't seem to find any answers . . .
I'm running MediaWiki 1.26.2, which uses ResourceLoader to load jQuery.
I've defined a function in MediaWiki:Common.Js as below:
//internal load function
function testLoad() {$(document).ready(function(){
$.ajax({
url:'some_internal_url',
type:'get',
dataType:'html',
success:function(data) {
alert('testLoad was successful!');}
})
});
}
This function runs fine in the console when I call testLoad(). However, when I try to call if from my app using the
Widgets Extension I get either a "$ is not defined" error or a "testLoad is not defined" error. In the first case, I use jQuery in my widget, as below:
<script src="text/javascript">
$(document).ready(function(){
testLoad();
});
</script>
and in the second case, I just call my function without jQuery, as below:
<script src="text/javascript">
testLoad();
</script>
I think this has something to do with my scripts loadings before JQuery has loaded, but I'm not sure how to fix it. Maybe I should be using a different extension to load my jQuery/javascript? Many thanks for any ideas.