On 04/25/2011 12:32 PM, Max Semenik wrote:
On 25.04.2011, 18:43 Tod wrote:
I've modified Mediawiki:Common.js to include
the following:
document.getElementById("p1").innerHTML="New text!";
I then created a page called testPage and
inserted:
<p id="p1">Hello World!</p>
I'm expecting the text to change upon load
but nothing is happening.
Prior to the<p> tag addition I had an alert that was working as
expected so at least I know Common.js is working.
What is the best practice for adding custom
javascript code in
Mediawiki? While we're at it is there a real good tutorial on including
AJAX calls w/o needing an extension anywhere?
$( document ).ready( function() {
$( '#p1' ).html( 'New text by jQuery!' );
});
Now that I've got this working I tried to replace it with a jQuery AJAX
call (test.php returns some canned JSON data):
$j(document).ready(function() {
alert("Ready...");
var
strURL="http://test.server.com/test.php".php";
alert("Making ajax call...");
$j.ajax({
type: 'GET',
url: strURL,
async: false,
cache: false,
dataType: 'json',
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus);
}
success: function(data,status,request){
$j( '#p1' ).html(data);
}
})
})
Nothing is returned, not even an error. Is this supported on MW 1.6.15?
Thanks - Tod