Possible Duplicate:
Why is this function returning “undefined”?
Let's assume I have the following JS function:
function getTileData(x, y, loc_slug) {
    $.ajax({
        url: "/sys/map-admin/show-location/"+loc_slug+"/get-tile/"+x+"-"+y+"/",
        success: function(data){
            alert(data); // Object, that's correct.
            **What do I need to make the whole getTileData function return data?**
        }
    });
}
and I call it within another function like
tile = getTileData(1, 2, 'asd');
alert(tile); // undefined
 
     
    