Skip to content

Instantly share code, notes, and snippets.

@gartenfeld
Last active April 22, 2016 22:32
Show Gist options
  • Select an option

  • Save gartenfeld/56d27e073c45fdce52bfabb69cfdec40 to your computer and use it in GitHub Desktop.

Select an option

Save gartenfeld/56d27e073c45fdce52bfabb69cfdec40 to your computer and use it in GitHub Desktop.
YQL CORS jQuery Plugin
// http://james.padolsey.com/snippets/cross-domain-requests-with-jquery/
// enableCORS();
var enableCORS = function() {
jQuery.ajax = (function(_ajax){
var api = 'http://query.yahooapis.com/v1/public/yql',
query = 'select * from html where url="{URL}"';
return function(o) {
var q = query.replace('{URL}', o.url);
o.url = api;
o.dataType = 'json';
o.data = {
q: q,
format: 'json'
};
return _ajax.apply(this, arguments);
};
})(jQuery.ajax);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment