因此,显然,我不能使用<a>将POST请求发送到另一个页面。我在某个地方读到过(我认为是这样),我可以使用适当的CSS格式提交按钮来假装某个链接,然后用它进行POST,但我不知道该如何做--到目前为止,我发现的所有方法都局限于发送按钮的“value”参数( AFAIK是它的标签),但我想发送其他信息。
POST信息的链接,这个链接不在它重定向到的PHP页面的文本中。POST。我怎样才能做到这一点?
发布于 2016-04-30 23:32:51
你可以用隐藏的输入来做这件事。即输入type=“隐藏”。在表单操作中,您需要放置需要提交的url。
至于让提交看起来像一个链接,您需要使用一些CSS
css
input[type="button"], input[type="button"]:focus, input[type="button"]:active,
button, button:focus, button:active {
/* Remove all decorations to look like normal text */
background: none;
border: none;
display: inline;
font: inherit;
margin: 0;
padding: 0;
outline: none;
outline-offset: 0;
/* Additional styles to look like a link */
color: blue;
cursor: pointer;
text-decoration: underline;
}html
<form action="#" method="post">
<input type = "hidden" name = "foo" value = "foo">
<input type = "hidden" name = "bar" value = "bar">
<button type = "submit">Click me!</button>
</form>Codepen Demo
https://stackoverflow.com/questions/36961267
复制相似问题