How to implement callback after $.php call?

How to implement callback after $.php call?

Hi!

I have a php function that imports some data into a database and saves the import results in a cookie. This is controlled in javascript by three functions:

function importCSV(filename){
    do_importCSV(filename);
    callback_importCSV();
}

function do_importCSV(filename){
    javascript:$.php(url,{'act':'importCSV','file':filename});
}

function callback_importCSV(){
    var importResultArray = get_cookie('importResults').split(",");
   
    alert('Import result: \n' +...

}

The function importCSV is called first, and in turn it should call do_importCSV and callback_importCSV. The problem is that the alert is shown before the import has finished, displaying either null or old information. I would like the callback_importCSV to function as a real callback function to be executed not before the importCSV function has completed. How to implement this?