jQuery function return

jQuery function return

Hi,
I'm very new to jQuery, only picked it up yesterday, so there is very little I understand at the moment. I have a website on which I would like to display a real time, time-series chart displaying results from a database that is constantly updated.
I asked for some help on stack-overflow about how to pull live data from my database and display it in an alert box on my sight. One of the replies said I should use jquery to achieve this. The code suggested is below

function

getNum() {
    $.ajax({
        url
: "getData.php",
        complete
: function(response) {
            alert
("The latest number in the database is " + response.responseText);
       
}
   
});
}
As you can see this jquery function runs a php request that grabs the latest integer that was added to my database, and displays it in an alert box.
My question is how do I get the jquery function genNum() to return the integer and not do display it in an alert box. I have tried adding in a return statement, but it seems to return some kind of object request, and not an integer as I was expecting.