【发布时间】:2010-11-09 19:36:20
【问题描述】:
我正在尝试构建一个 jQuery 函数,该函数允许我出于微博原因(是的,twitter)从其他链接生成 TinyURL...我从 James 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);
});
【问题讨论】:
-
检查您的 Javascript 控制台(Firefox 中的工具 > 错误控制台),或使用 Firebug 的控制台 - 它可能会提供有用的错误消息
标签: jquery jquery-plugins tinyurl