我有一个执行 DELETE 请求的 HTML 表单(method = POST & 隐藏的 X-HTTP-Method-Override = DELETE)
当 DELETE 请求成功时,如何告诉浏览器重定向到另一个页面?
303+标头位置可以吗?
目前,浏览器不会显示空响应,而是保留之前的响应(我猜是因为 204 状态代码)。
如果我添加位置标头(仍然是 204 状态代码),它不会更改位置。
使用 303+location 我有所需的行为,但我想知道 303 是否是成功删除后的有效状态代码。
202(已接受)删除怎么样?
I have an HTML form performing a DELETE request (method = POST & hidden X-HTTP-Method-Override = DELETE)
When the DELETE request is successful, how do I tell the browser to redirect to another page?
Is 303 + header location okay?
Currently, the browser doesn't display the empty response but keep the previous response (I guess because of the 204 status code).
If I add a location header (still 204 status code) it does not change the location.
With 303+location I have the desired behavior but I wonder if 303 is a valid status code after a successful DELETE.
What about 202 (Accepted) DELETE ?
发布评论
评论(1)
303加位置是最好的选择。不必担心“成功的 DELETE”是什么或意味着什么,因为您使用的是 POST,它具有一组不同的语义,并且 303 是为 重定向 POST 请求:
303 plus Location is the best choice. Don't worry about what a "successful DELETE" is or means, because you're using POST, which has a different set of semantics, and 303 is tailor-made for redirecting POST requests: