Cross Domain AJAX Request with YQL and jQuery

jQuery snippet to make a cross domain request.

function requestCrossDomain(url, callback) {
    var yql = "http://query.yahooapis.com/v1/public/yql?q=" +
            encodeURIComponent('select * from html where url="' + url + '"') +
            "&format=xml&callback=?";
 
    jQuery.getJSON(yql, function (data) {
        try {
            callback(data.results[0]);
        } catch (e) {
            console.log("Callback failed:", e.toString());
        }
    }).fail(function (jqxhr, textStatus) {
        console.log("Request failed:", textStatus, url);
    });        
}

Source