I'm making the following
function handler(data)
{
    return data;
}
function hit_db()
{
    $.ajax({
        url: target_url,
        type: 'GET',
        async: true,
        crossDomain: true,
        success: function (response){
            handler(response);
        }
    });
}
var status = hit_db();
return status;
However, if I try to alert(status) I get undefined
I know this is due to the async nature of ajax calls but I still can't seem to return response from the server successfully.
Curiously enough, If I write this
function handler(data)
{
    return data;
}
function hit_db()
{
    $.ajax({
        url: target_url,
        type: 'GET',
        async: true,
        crossDomain: true,
        success: function (response){
            alert(response);  // <---- Change is here
        }
    });
}
var status = hit_db();
I get it alerts the desired output success
Why is this happening? Isn't my callback function not setup properly? I have tried some online solutions but none seem to attempt to return a server response
