HTML – 有没有办法忽略表单响应?

前端之家收集整理的这篇文章主要介绍了HTML – 有没有办法忽略表单响应?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法通过类型或操作URL指定表单以不打开响应?换句话说,我想将信息发送到服务器,但不在客户端上做任何事情.我知道我可以使用ajax并忽略响应,但我想避免在可能的情况下将所有j添加到我的代码中.

编辑:我不是故意将自己限制在html表单中.在我看来,服务器端解决方案也是可以接受的

解决方法

在表单提交后让服务器返回HTTP 204(无内容).根据 the HTTP 1.1 spec

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.

这听起来就像你想要的.

原文链接:/html/231565.html

猜你在找的HTML相关文章