Javascript - using in function defined variable
<p>I want to execute this function and use the variable outside the function, but inside an each fucntion. How can I get this work?</p>

<pre><code>$('.social').each(function() {
    url = "http:www.google.com";
    bit_url(url);    
    $(element).append(urlshortened);
});

function bit_url(url) {
        var url = url;
        var username = "...";
        // bit.ly username
        var key = "...";
        $.ajax({
            url : "http://api.bit.ly/v3/shorten",
            data : {
                longUrl : url,
                apiKey : key,
                login : username
            },
            dataType : "jsonp",
            success : function(v) {
                urlshortened = v.data.url;
            }
        });
    }
</code></pre>

<p>Thanks guys!</p>
