11

It is very strangely, but my HTML form send data via GET, not POST.

    <form name="mistake" action="http://web-server.com:8888/WebApp/Email/Create" method=post>
  <input type="text" name="url" size="50" readonly="readonly">
          <br />
          <span class="text">
          Error :
          </span>
          <br /> 
          <textarea rows="5" name="mis" cols="37" readonly="readonly"></textarea> 
          <br />
          <span class="text">
          Comment :
          </span>
          <br /> 
          <textarea rows="5" name="comment" cols="37"></textarea> 
          
          <input type="hidden" name="email" value="[email protected]">
          <input type="hidden" name="subject" value="Errors">
          <div style="margin-top: 7px"><input type="submit" value="Submit">
          <input onclick="hide()" type="button" value="Close" id="close" name="close"> 
          </div>
</form> 

I test it on IE10 with standart options.
HTML form very simple and i write only little example of code.
How to fix it?
Thank you!

P.S. Change URL. This URL web-server.com:8888/WebApp/Email/Create - belongs to asp mvc app.

When i run my web app and ths static site on local machine- it works. But when i runs static page on local machine- and mvc on server- it not works.

P.P.S.- this variant of form- is origine (i cut some tags). Now it is origine.

I dont why, but it works. May be - problem on server side?

6
  • 1
    Unless you are doing something dynamic with JavaScript, it should use POST. (Also, do make sure to include valid HTML - in this case at least the form closing tag is missing; and a fiddle test-case goes a long way in reproducing the claimed behavior.) Commented Jan 21, 2014 at 11:16
  • Do you have defined the hide() function. Commented Jan 21, 2014 at 11:21
  • I think something in hide() function avoiding the page from posting. Commented Jan 21, 2014 at 11:23
  • hide() function defined (i dont know where, but when hide() runs- form closes. Commented Jan 21, 2014 at 11:23
  • Is it something similar to this question (I see in your example you are missing </form>):stackoverflow.com/questions/8653893/… Commented Jan 21, 2014 at 11:30

8 Answers 8

25

The problem is rather common and the answer quite elusive:

Somewhere in your code you have an orphaned <form>. This means that the next form is nested in the previous one, and its method is ignored. Delete or close the superfluous <form> and you are done.

Sign up to request clarification or add additional context in comments.

Comments

5

It should be a post (assuming that you forgot the closing tag only in your example). I added your code and put the closing tag in an html file and submitted in Chrome. This is what I see in the network trace:

enter image description here

Also look at this question in case you are doing the same.

2 Comments

I agree with the "should be a post". I believe the OP is hiding something (in hide even).
@user2864740 - agree, it is something like that.
5

A web application framework I am using automatically redirects POST requests for the action URL to the same URL with a trailing slash. HTTP redirection downgrades POST to GET.

1 Comment

@AdmiralLand I forgot how I got a similar puzzle. My trying to reproduce showed the redirection in a contrived example where a flask server route ends with a trailing slash, accepts both GET and POST, and where the client sends a POST request without the trailing slash.
1

I did have the same problem once here what i did: the problem first come when a form is nested inside another one, and its method is ignored.

the solution is pretty simple: Delete or close the superfluous and you're good to go .

Comments

1

This post helped me fix what was causing the issue for me.

If IIS Manager redirects the url, it changes a POST request to a GET request. I had to change the server to re-write the url instead of redirect it.

I also had to enable Application Request Routing in IIS Manager. I followed the instructions in this post.

Comments

1

(In my case, I found some causes.)

There can be many causes two of them are:

  1. If forget to close the form tag.

  2. Written post in a wrong way. i.e. It should be something like this:

    <form action="index.php" method="post">

If you write method=post , method ="POST"or method ="Post" then it will not work. Hope it will solve your problem.

Comments

0

Try method="post" instead of method=post

1 Comment

It won't make a difference. The quotes are optional around simple HTML attribute values. See w3.org/TR/html-markup/syntax.html#syntax-attributes
0

May simply be that your user-agent is ignoring the form method because you haven't put quotes around the attribute.

Try:

 <form name="mistake" action="http://web-server:8888/WebApp/Email/Create" method="post">

8 Comments

No, it's not. Quotes don't matter around simple HTML attribute values. This is the 3rd time such as been suggested :) See w3.org/TR/html-markup/syntax.html#syntax-attributes
It depends on the user-agent and the form of HTML. It's not a 'given'.
The UA is IE10. Any UA that doesn't accept simple (unquoted) attribute values is not a functioning HTML4/5 UA - even IE6 understands this syntax (which was kept/codified for backwards compatibility, not added as a cool HTML5 feature). And XHTML is not HTML.
The doctype wasn't specified, nor would it have been reasonable for me to assume the doctype was being applied correctly.
None of your comments have been relevant or counter my claims. This answer is wrong.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.