Create a TinyURL with JQuery and JSONP
- Thursday, December 25, 2008, 16:20
- JQuery
- 2 comments
jQuery 1.2 introduced JSONP support.JSONP is script tag injection, passing the response from the server in to a user specified function.
function tinyUrl(url,success)
{var apiLink= ‘http://json-tinyurl.appspot.com/?url=’,
link=apilink+encodeURIComponent(url) + ‘&callback=?’;$.getJSON(link,function(data){
success && success(data.tinyurl);
});}
tinyUrl(‘http://httpguru.com/adobe-galla/adobe-flex/downloading-and-installing- flex-sdk-builds-into-flex-builder-3/’,function(tinyurl) {
alert(tinyUrl);
});
Popularity: 16% [?]
About the Author
2 Comments on “Create a TinyURL with JQuery and JSONP”
Write a Comment
Gravatars are small images that can show your personality. You can get your gravatar for free today!
Thanks Vinoth babu! I used your code to work with to.ly, see http://to.ly/api_info.php
Its glad to hear someone has used my code in his website.