Skip to content Skip to sidebar Skip to footer

Post Form Keeps Making Get Request

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 %>

Solution 1:

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

Solution 2:

button_to defaults to POST...

it will default to performing a POST operation

Since you've not explicitly set your method as GET, this suggests you have an issue higher up the browser stack.


A clue can be found within the link_to documentation:

Note that if the user has JavaScript disabled, the request will fall back to using GET

Specifically, that your javascript is either disabled or erroneous; a common problem which results in the functionality you're experiencing.

--

The fix is to make sure your Javascript is working properly. The simplest way to do this is to load up the "developer console", to which you'll be able to see any errors in the Javascript.

In Chrome, you can Right-Click > Inspect Element - this will show the console, from which you'll be able to identify any of the errors your JS is returning:

enter image description here

If you do that, I'll be in a better position to help you resolve any of the issues it may have.

Post a Comment for "Post Form Keeps Making Get Request"