Javascript global variables issue
===

The below snippet doesn't get me the value of the global var id displayed in my console. Where am I going wrong?

    var id;
    
    function set_id(myid){
     id=myid;
    }
    
    function get_id(){
     return id;
    }
    
    $("#btn").click(function(){
     $.post("....", function(data){ //data reurns a JSON
      set_id(id); //success!!
     }
    }
    
    $("#show").click(function()[
     console.log(get_id()); //doesn't work, how do I get this workin.. Where am I going wrong
    }