Tabs beforeActivate: Using ajax result for return true/false fails

Tabs beforeActivate: Using ajax result for return true/false fails

Hi,

I try to use a ajax result for a true/false return in a function, but it doesn't work. I have read all about the stuff
here so i built the following code:

  1. $( ".selector" ).tabs({ beforeActivate: function( event, ui ) {
          validateSession().done(function(r){
                if (r.session)
                      return true;
                else
                      return false;
          });
    });

    function validateSession() { return $.ajax({ url: check.php, data: { session_check : true }, type: 'POST', dataType: 'json' }); }
check.php is a simple print json_encode(array("session" => true/false));
The problem is that even if r.session is false, the beforeActivate function always returns true.
It seems that it doesn't wait for the ajax call.
Any help would be appreciated!

Kind regards, Matty