什么时候jQuery.ajax()完成{}?

jQuery.ajax() is "a function to be called when the request finishes". Suppose I'm making an ajax request to ajax.php:

<?php

echo 'complete';

some_functions_that_echo_nothing();

?>

Will the complete have to wait for some_functions_that_echo_nothing()? If so, is there a way to make the complete{} occur right after the echo and still have the ajax.php run through till the end?

I'm guessing you want to output "Complete" and let that function run in background, since it's very slow.

In that case put this function in a separate file. Let it be proc.php and use this instead:

<?php
    echo "Complete';
    exec ("/usr/bin/php proc.php >/dev/null &");
?>

That will return right away and fire the proc.php file to run on background. Of course it won't be able to output it's return to the user, so it should mail the user when he's done, or do his own persistence.

EDIT: ALWAYS take grea care of what you put inside exec statements. Never put user inputs into it if you are not 100% sure you are sanitizing it very carefully. Even so, you really don't have a good reason to use User input into an exec call.