I'm working on a php-ajax chat, and I use two main methods: "update" and "send"
Update function (ajax):
$.ajax({
type: 'POST',
timeout: 9999999999999999,
url: 'process.php',
success: ...
});
Process.php:
function update(){
if(new messages){
echo new messages...
}else{
sleep(5);update(); again...
}
}
Send function (ajax):
$.ajax({
type: "POST",
url: "send.php",
success: function(){
update();}
})
I want to stop running "update" request when sending new message and start it again immediently, so sender will instantly see his message. I have tried ajax.abort() but it can still continue to execute the call on server side.
How can I complete the ajax call and make return success, not aborting it?