0
4

4 回答 4

1

替代方案:您可以使用 javascript 修改锚标记发出的请求,

或者

使用表单,并通过将提交按钮设置为看起来像链接来模拟锚点

于 2012-09-03T04:03:48.570 回答
0

在 html 文件中,锚文件不支持 POST 值。

您只能通过 form 标签获取 html 文件的 post 值。

<form action="test.php" method="post" > <input type="text" name="lname" /><br /> <input type="submit" value="Submit" /> </form>

于 2012-09-03T04:01:07.033 回答
0

正如 Matt Ball 评论的那样,您可以使用表单而不是 JS 来完成此操作:

<form method="post" action="YOUR_ACTION">
    <input type="hidden" name="foo" value="bar" />
    <input type="submit" value="link" class="submitLink" />
</form>

然后将提交设置为看起来像常规链接:

<style type="text/css">
input.submitLink {
    background: none;
    border: medium none;
    color: blue;
    cursor: pointer;
    margin: 0;
    padding: 0;
    text-decoration: underline;
}
</style>
于 2012-09-04T01:32:08.333 回答
0

您可以使用要提交的值创建隐藏表单;并且您链接可以触发该submit()表单上的操作。这很容易用 jquery(或你最喜欢的 javascript 库)完成。

这是未经测试的,但应该这样做:

<form method="POST" id="the_form" action="foo/">
  <input type="hidden" name="bar" value="baz" />
</form>

<a href="#" id="submit_link">Send values</a>

<script type="text/javascript">
  $('#submit_link').click($('#the_form').submit());
</script>
于 2012-09-03T04:09:55.633 回答