.ajax within a function

.ajax within a function

Being new to this, I have a problem with what I believe to be a simple question.  Why is 'undefined' being returned from the function below?

  1. function validate_manager(manager_id) {
  2. var a = $.ajax({ 
  3. type: "POST",
  4. dataType:"JSON",
  5. data: {
  6. ajaxCall: 1,
  7. manager_id: manager_id
  8. },
  9. url: "/system/php/ajx_check_username.php",
  10. async: false   // Wait for completion ......
  11. });
  12. a.done(function(data) {
  13. console.log(data);
  14. return data;
  15. });
  16. a.fail(function(response) {
  17. var data = {
  18. success: false,
  19. error_message: response.status+':'+response.statusText
  20. };
  21. console.log(data);
  22.     return data;
  23.   });
  24. }

The console.log is outputting what I want, but the calling function gets 'undefined',

Sure this is simple, but its breaking me now!!