jQuery.ajax cross domain request with script

jQuery.ajax cross domain request with script


Hi there,
I am having a problem with the cross domain issue that AJAX has.
According to jQuery.ajax documentation, it should handle cross domain
request with "script" and "jsonp" as data type. However, I cannot
manage to get the following works:
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/
libs/jquery/1.3/jquery.min.js'></script>
<script type='text/javascript'>
    function getGeoLocation() {
        var location;
        alert('started');
        $.ajax({
            type: "GET",
            url: "http://j.maxmind.com/app/geoip.js",
            success: function () {
alert('success');
location = geoip_city();
},
            error : function () {alert('error');},
            dataType: "script"
        });
        alert(location);
        alert('finished');
    }
</script>
<body onload="getGeoLocation()"></body>
There is no error according to FireBug, all alerts were executed
except the ones in 'success' and 'error' functions. The above example
is very similar to something in Ubiquity developed by Mozilla, it
works even with dataType: "text", but in the 'success' function, it
passed down a parameter and eval it. (I wonder whether in Mozilla it
has a proxy to handle such request)
jQuery.getScript() can handle cross domain request for sure, and it is
based on jQuery.ajax with hardcoded dataType: "script", however, I
still want to have the request made on jQuery.ajax because it provides
more controls.
Can anyone please let me know why my example does not work, thanks!!