POST表单并防止响应 [英] POST form and prevent response

查看:120
本文介绍了POST表单并防止响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下形式:

 < form method =postaction =http:// domain。 ?COM / api.json PARAM =值>< /形式> 

在提交此表单时,这将用 http://domain.com/api.json



是否可以发布此表单,但是阻止接收回复,并保留现有的HTML与形式

解决方案

发送HTTP 204否内容响应而不是通常的200 OK响应。


10.2.5 204无内容



服务器已完成请求,但不需要返回
实体主体,并且可能想要返回更新后的元信息。
响应可能包含新的或更新的元信息,形式为
实体标题,如果存在的话应该与
请求的变体相关联。



如果客户端是用户代理,则不应将其文档视图
更改为导致请求发送的文档视图。这个回应是
,主要是为了允许在没有
导致用户代理的活动文档视图发生变化的情况下进行动作输入,尽管
任何新的或更新的元信息应该应用于文档
当前在用户代理的活动视图中。

204响应绝不能包含消息体,因此总是
被第一个空在标题字段之后。



I have the following form:

<form method="post" action="http://domain.com/api.json?param=value"></form>

On submission of this form, this will replace my document with a response from http://domain.com/api.json.

Is it possible to POST this form, but prevent receiving a response, and keep the existing HTML with the form?

解决方案

Send an HTTP 204 No Content response instead of the usual 200 OK response.

10.2.5 204 No Content

The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.

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.

The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.

这篇关于POST表单并防止响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆