Hello.
I'm trying to get working some AJAX make statistics of links clicked. Using php and mysql as back-end. My choice is synchronous AJAX request to server using onbeforeunload event. I'm using synchronous request to be sure that browser sent request to the server before page is unloaded. With asynchronous request much requests do not get to the server especially with slow connections.
This approach works well so far, but as mysql database gets bigger, and php script more complicated, this will take more time to proceed request, which forces browser to wait a little before response is sent back to it.
I just thought is there any way to send response to browser, close the connection (this normally happens after exit or die() in php script) and only after that continue script execution. So we will be sure that request is sent to server, and browser will not wait so long until php executes all the back-end logic. I've tried
header("HTTP/1.0 200 OK");
header('Status: 200 OK');
header("connection: close");
but no success so far.
Any ideas how to do it?