I've got a bit of a stupid question here. I know the whole Asynchronous aspect of AJAX and how it messes up my code here. Basically I have this function and as the name suggests, it checks if the user session is still valid.
    user_session_check: function() {
        app.http_ajax_json_post(app.config.settings.api_url + 'user/check', {
            action: 'session'
        }, function(data) {
            if (data.status == 0) {
                app.config.return = 0;
            } else {
                app.config.return = 1;
            }
        });
    }
Basically I need to check what that return value is (data.status will only ever equal -> 1 || 0). How would i be able to access that as even trying to set it as the variable value 
app.config.return = 0;
Does not work.
Please correct me if I'm wrong, but should i be using a callback to do what I need to do if the session is expired?
Note: Should I be doing something like this? : https://stackoverflow.com/a/9269326/2518525
Where I run the ajax request synchronously?
Thanks!
 
     
    