Update: This method has been deprecated from jQuery 1.9. Does not work any more.
Old answer:
Try this (updated):
$.support.cors = true;
$(function () {
$.ajax("http://commons.wikimedia.org/w/api.php?action=query&generator=allimages&gailimit=4&gaifrom=T&prop=imageinfo&iiprop=url&callback=?")
.complete(function () { alert('complete'); })
.error(function () { alert('error'); })
.success(function (data) { alert(data); });
});
Learn more about setting up jQuery.support.cors here: jQuery.support
P.S. ! , .