How to send few parameters via POST method?

I want to send parameters as Key-Value via POST. With GET method it easy to make:

myDomain.com? a=3&b=2&c=1

But how to make same request via POST method (I dont want to send all data as String with some delimiter and then parse this String on server via Split() method)?


The traditional format is the same. It just appears in the HTTP request body instead of as part of the URI. Whatever library you use to parse the query string should handle x-www-form-urlencoded data just as easily.

POST / HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded

a=3&b=2&c=1

You should use either form method = POST or ajax.

Jquery ajax is easier. Just google it. (if you want it that way).

Ps You can't send post parameters via url.


The most common way to send POST data is from an html form:

<FORM action="http://somesite.com/somescript.php" method="post">
   <P>
   <LABEL for="firstname">First name: </LABEL>
          <INPUT type="text" id="firstname"><BR>
   <LABEL for="lastname">Last name: </LABEL>
          <INPUT type="text" id="lastname"><BR>
   <LABEL for="email">email: </LABEL>
          <INPUT type="text" id="email"><BR>
   <INPUT type="radio" name="sex" value="Male"> Male<BR>
   <INPUT type="radio" name="sex" value="Female"> Female<BR>
   <INPUT type="submit" value="Send"> <INPUT type="reset">
   </P>
</FORM>

Then process the $_POST vars similar to how you would with $_GET vars in PHP.

链接地址: http://www.djcxy.com/p/45862.html

上一篇: 如何使用C#发送POST请求中的json数据

下一篇: 如何通过POST方法发送少量参数?