jquery variable not being set within function.asynchronous?
<p>i think this has something to with the function being asynchronous but i'm not sure. i think it's a quick answer but i can't figure it out.</p>

<p>i'm trying to check if images exist on the server. if they do, then set a variable. if they don't then move on and check the next image.</p>

<p>every time i alert the variable though i keep getting 0. i know the urls are correct and everything. for some reason though i can't get the variable. any tips?</p>

<pre><code>    $('.rightPostContent img').each(function(){
            var c = $(this).attr('src');
            var pot1 = c.replace('_B.png','_pt1.gif');
            var pot2 = c.replace('_B.png','_pt2.gif');
            var pot3 = c.replace('_B.png','_pt3.gif');


        $.get(pot3)
            .done(function() { 
                var t = 3;
            }).fail(function() { 
        })  
        $.get(pot2)
            .done(function() { 
                var t = 2;
            }).fail(function() { 
        })          
        $.get(pot1)
            .done(function() { 
                var t = 1;
            }).fail(function() { 
        })  
        alert(t);
    });
</code></pre>

<p>the variable <code>t</code> wont alert anything, even though all <code>pot</code> images exist in this example.</p>
