RSo*_*erg 5 jquery jquery-plugins tinyurl
我正在尝试构建一个jQuery函数,这将允许我从其他链接生成一个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);
});
Run Code Online (Sandbox Code Playgroud)
嗯这似乎对我很好:
function makeTinyUrl(url)
{
$.getJSON('http://json-tinyurl.appspot.com/?url=' + url + '&callback=?',
function(data)
{
alert(data.tinyurl);
}
);
}
makeTinyUrl('http://stackoverflow.com/questions/1111171/how-to-use-jquery-to-produce-tinyurl');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3619 次 |
| 最近记录: |