Question

Will someone please help me with this jQuery bit.ly URL shortener?

The code is as follows:

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);
});

And whenever I run the script it returns this code in the console:

jsonp1304728172115({ data : [ ] , "status_code" : 500, "status_txt": "missing_arg_uri"})

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top