我试图建立一个jQuery的功能,让我从其他一些链接,微博的原因(是的,微博)产生TinyURL的...我发现从詹姆斯Padolsey本教程,但我不能从获取响应回呼叫。
http://james.padolsey.com/javascript/create-a-tinyurl-with-jsonp/
function requestShortURL(longURL, success) {
var API = 'http://reque.st/create.api.php?json&url=',
URL = API + encodeURIComponent(longURL) + '&callback=?';
console.log('tweet apit url: ' + URL);
$.getJSON(URL, function(data){
success && success(data.url);
});
}
requestShortURL('http://www.mycompany.com', function(shortened){
alert('new url: ' + shortened);
});