我需要在 ajax 操作中断开连接:
$response = getResponse($params);
echo $response; // don't make user to wait
flushAndDropConnection();
someLongActionsFor5Seconds();
我该怎么做?
我需要在 ajax 操作中断开连接:
$response = getResponse($params);
echo $response; // don't make user to wait
flushAndDropConnection();
someLongActionsFor5Seconds();
我该怎么做?
只需让用户断开连接,但让脚本运行。
ignore_user_abort(true);
ob_start();
echo "response";
$size = ob_get_length();
header("Content-Length: $size");
header('Connection: close');
ob_end_flush();
ob_flush();
flush();
if (session_id()) session_write_close();
//your long running action here