First of all, I'm using JQuery. Take a look:
$(document).ready(function() {
    var btcusd = 600;
    function getRate() {
        $.get("rate.php", function(data) {
            var btcArr = JSON.parse(data, true);
            btcusd = btcArr["last"];
            //This will give me the correct value
            console.log(btcusd);
        });
    }
    setInterval(function() {
        //This will say 600 every time
        console.log(btcusd);
        //Update rate for next loop
        getRate();
    }, 3000);
});
Chrome console gives me the 600 every 3 seconds. If I do this manually in the chrome live console, I will get a real value, like 595.32.
Why does this not work like intended? Thanks for help.
 
    