Alert at completion of PHP code execution behind Ajax button

I have some PHP code that makes a long-running external call behind an Ajax button. How do I get a “Done” message to pop up on the screen at the end of the process rather than immediately the button is clicked?