Possible Duplicate:
How to return the response from an AJAX call from a function?
on my App namespace i've just defined a function:
version 1
window.App = {
  isLogged: function () {
    $.get('/user/isLogged', function (data) {
      if (data == 'true') {
        return true;
      }
      return false;
    });
  }
};
version 2
window.App = {
  isLogged: function () {
    var test = $.get('/user/isLogged');
    console.log(test.responseText);
  }
};
On version 1 when i try the function on firebug 'App.isLogged()' i got a nice undefined :S
On version 2 when i try the function on firebug, the responseText seems to be undefined :stuck:
I'm pretty new about javascript, and maybe a scope issue...
The goal of my function is clear i think, there's a better way to achieve this?
 
     
    