有人請幫助我這個jQuery bit.ly URL縮短。代碼如下:請幫助jQuery的URL bit.ly縮短
function shortenUrl(urlMatch)
{
var urlMatch = urlMatch
var username="myusername";
var key = 'R_897b82b73568ea74fffbafa5a7b846d';
$.ajax({
url:"http://api.bit.ly/v3/shorten",
data:{longUrl:urlMatch,apiKey:key,login:username},
dataType:"jsonp",
success:function(v)
{
var shortUrl=v.data.url;
return shortUrl;
}
});
}
$('button').click(function(){
var urlMatch = $(this).val();
var newUrl = shortenUrl(urlMatch);
$('#menu').html(newUrl);
});
,每當我運行該腳本,它返回此代碼在控制檯:
jsonp1304728172115({ data : [ ] , "status_code" : 500, "status_txt": "missing_arg_uri"})
能有人幫。
缺少參數「format」:「json」?這裏是我的代碼版本: http://stackoverflow.com/questions/1771397/jquery-on-the-fly-url-shortener/7005673#7005673 – 2011-08-10 04:48:21