I'm not new to js but there's a stupid problem with jquery get method that it can't change global variable and I don't know why?
function getData(data) {
    re=null;
    $.get("http://example.com/api.php",{ d:data}).done(function(result){
            re = true;
        }).fail(function(){
            re = false;
        });
        console.log(re);
        return re;
}
If you see the console it's still null !
Any ideas?
UPDATE : 
My problem is not with console.log() , actually the problem is that I cant store and return value like this : 
alert(getData(data));
This still returns null.
 
    