Created
May 16, 2010 00:05
-
-
Save aaronmcadam/402525 to your computer and use it in GitHub Desktop.
Small function for easier YQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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