HTML form send data by GET instead POST

2019-07-10 04:41发布

问题:

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="admin@admin.com">
          <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?

回答1:

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:

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



回答2:

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.



回答3:

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.



回答4:

Try method="post" instead of method=post



回答5:

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 .



回答6:

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


标签: html post get