POST 表单不断发出 GET 请求 [英] POST form keeps making GET request

查看:46
本文介绍了POST 表单不断发出 GET 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个只有一个提交按钮的表单.这是我在视图中的代码:

I created a form with only a submit button. Here is my code in the view:

<%= button_to searches_send_request_path, class: "btn btn-warning", id: "contact" do %>
  <i class="fa fa-envelope"> &nbsp; Send Request</i>
<% end %>

在 Chrome 开发者工具中,它以 HTML 格式显示表单:

In the Chrome developer tool, it shows the form in HTML:

<form class="button_to" method="post" action="/searches/send_request"> 
  <button class="btn btn-warning" id="contact" type="submit">
    <i class="fa fa-envelope"> &nbsp; Send Request</i>
  </button>
</form>

但是,当我单击按钮时,它不断发送 GET 请求.知道发生了什么吗?

However, when I click the button, it keeps sending a GET request. Any ideas what is going on?

推荐答案

您提供的 HTML 使用 POST 提交表单,这是肯定的.可能你有一些 JS 代码将 POST 替换为 GET.

The HTML you provided submits form using POST, that's for sure. Probably you have some JS code replacing POST to GET.

这篇关于POST 表单不断发出 GET 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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