Store result from ajax API call into Var | jQuery

I am able to get result from ajax API Call and want to store result into var, but the result does’t store into var. Please help me to achieve this. Below is the code for ajax response:-

var Name = '';

function webservice_returnResult(apiURL, id) {
    return $.ajax({
        type: 'GET',
        url: baseurl + '/' + apiURL,
        data: { "Id": id },
        dataType: 'JSON',
        //async: true,  //NOT NEEDED
        success: function (response) {
            //Data = response;
        }
    });
}
 
    webservice_returnResult('api/sample/GetById', Id).done(function (result) {
        Name = result.Name;
    });
  
    console.log(Name);

result.Name does’t save into var Name.