Is it possible to make such a HTTP response, that the browser ignores it and keeps showing the previously displayed page?
I mean the following scenario:
a) user clicks something
b) some POST goes to the server (or GET, but let's stick with POST as more interesting)
c) server decides that for some reason it does not want to send the reply at this time
d) server sends specifically crafted response
e) browser does not show the error page, does not show the empty page, does not redirect anywhere, does not reload - just keeps showing what it was showing as if the user never submitted the form
PS Of course it can be wrapped with AJAX, but I ask whether bare-bones non-javascript solution is possible
Try returning HTTP 204 No Content. See the description of this response code in RFC 2616 (Hypertext Transfer Protocol -- HTTP/1.1 ) where it says:
If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.
This is a method usually called AJAX. It requires Javascript, and the XMLHttpRequest function.
Edit: Noticed your 'PS' at the bottom. The 204 response suggested in another answer looks like it might be a valid non-Javascript solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With