I have following code
function getUser(){
    var user;
    $.post('php/function/getSessionData.php', {
        action: "getUser" 
    }).done(function(response){
        user = $.parseJSON(response);
    });
    console.log(user); //in console its displayed as object like excepted.
    return user;
}
This function calls a php file and should return data what is stored in the session array.
My PHP file looks like this:
<?php
    session_start();
    switch($_POST['action'])
    {
        case "getUser":
                    echo json_encode($_SESSION['user']);
                    break;
        default: break;
    }
?>
Actually everything works fine. Data is recived and all....
now in my jquery i have some like this to call this all:
$(document).ready(function(){
    $(".myButton").on("click", function(){
        console.log(getUser());
    });
});
of course there is some more source but this part is my problem.
it returns 'undefined'. Usual i can pass objects by return don't i ?
why does my source returns 'undefined' ?
 
    