how to get a return value from a ajax callback

how to get a return value from a ajax callback

Hi everyone,

here is my function:

function test(){
      $.ajax({
         type: "POST",
         url:"/ajax/test/",
         data: { ...]
         dataType: "json",
         success: function(data){
            return true;
   
         }
      });
   }
}


How would be possible to get the return of the callback function in the test() function in order to make something like:

function test(){
      return $.ajax({
         type: "POST",
         url:"/ajax/test/",
         data: { ...]
         dataType: "json",
         success: function(data){
            return true;
   
         }
      });
   }
}


In advance thanks