Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created May 16, 2010 00:05
Show Gist options
  • Save aaronmcadam/402525 to your computer and use it in GitHub Desktop.
Save aaronmcadam/402525 to your computer and use it in GitHub Desktop.
Small function for easier YQL
$.YQL = function(query, callback) {
if (!query || !callback) {
throw new Error('$.YQL(): query or callback are undefined');
}
var encodedQuery = encodeURIComponent(query.toLowerCase()),
url = 'http://query.yahooapis.com/v1/public/yql?q='
+ encodedQuery + '&format=json&callback=?';
$.getJSON(url, callback);
};
//Usage:
jQuery(document).ready(function(){
$.YQL('select * from flickr.photos.search where tags="cats, lol" and tag_mode="all" limit 10', function(data) {
//Handle returned json data here
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment