Send AJAX results but continue processing in PHP

前端 未结 2 1810
名媛妹妹
名媛妹妹 2021-01-19 04:07

I\'m using AJAX to update some values in a database. All has worked wonderfully with that, but now I would like to implement some logging stuff. The logging functions look

相关标签:
2条回答
  • 2021-01-19 04:42

    Well, you would see it, wouldn't you? You told it to echo!

    In all seriousness, your example should work. It seems that code is executing after the flush, so you should be able to do your logging if the flush sent the request to the browser.

    0 讨论(0)
  • 2021-01-19 05:01

    The PHP script cannot tell the browser to close the connection and not wait for further data. Using flush(); only sends the current output down the chain, to the web server, but it does not guarantee it will arrive to the browser immediately. The web server may cache the output until the PHP script completes the execution.

    As the OP wrote in the last paragraph, the solution is to configure Apache to not buffer the results.

    0 讨论(0)
提交回复
热议问题