如何以编程方式向 PHP 中的 ajax 请求返回 200 ok 状态?
我问这个问题是为了对此答案的评论:
https://serverfault.com /questions/104648/is-this-http-servers-issue/104679#104679
编辑
我错过了重要的一点,还应该保持连接不关闭。
你们可以闻到我正在尝试找出轮询实际有效的时间。
I ask this question for the comment of this answer:
https://serverfault.com/questions/104648/is-this-http-servers-issue/104679#104679
EDIT
I missed an important point,should also keep the connection not closed.
You guys can smell I'm trying to figure out how long polling actually works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只要不出问题,就会出现 200 OK。因此,只要 HTTP 请求成功,您就应该始终获得该状态。不需要做任何特别的事情。
200 OK happens as long as nothing goes wrong. So you should always get that status as long as the HTTP request succeeds. No need to do anything special.
从 PHP 5.4.0 开始,您可以使用
http_response_code()
:
As of PHP 5.4.0 you can use
http_response_code()
:要完成 hitautodestruc post,使用 PHP <5.4,您也可以设置
..但是以任何方式发送 200 代码都是无用的,因为在请求完成时默认情况下已经发送了它,并且如果服务器端没有发生错误(5xx)
也许您正在寻找这样的东西?
to complete hitautodestruc post, with PHP <5.4 you could also set
..but sending 200 code in any way is useless, since it is already sent by default when request completes, and if none error occurs otherwise on server-side (5xx)
maybe you are looking for something like this ?