I want to send an AJAX call to a server that makes phone calls to our clients. However, I don't want the person who starts the process to have to leave their browser open. After some research, I've found that I can pass a header in php normally to allow the browser to disconnect without the php execution stopping. Will this work for AJAX as well? The relevent code is below.
//jQuery 1.8.10
$('#start').click(function(){
    $.post('/startcalling', {
        'time_limit': 0
    });
});
$('#stop').click(function(){
    $.post('/stopcalling');
});
The important PHP
function startCalling(){
    echo "starting...";
    header('Connection: close');
    while(getFlagStatus()){
        makeNextCall();
    }
}
function stopCalling(){
    if(!getFlagStatus()){
        $query = "UPDATE cc_flags SET cc_on = 0";
        mysql_query($query);
    }
}
I could package this into a CLI command, and accomplish my goal, but I feel like there has to be an easier way. If I've been confusing, let me know and I'll edit.
EDIT: Does php execution stop after a user leaves the page? Does this apply here?
 
     
    