【问题标题】:with a standard html form post, no body带有标准的 html 表单帖子,没有正文
【发布时间】:2020-12-15 02:23:32
【问题描述】:

我有这个表格:

<form action="/signup" method="post">

                <div class="field">
                    <label class="label">{{ message }}</label>
                </div>

                <div class="field">
                    <label class="label">Name</label>
                    <div class="control">
                        <input class="input" type="text" placeholder="Text input" value="joe">
                    </div>
                </div>



                <div class="field is-grouped">
                    <div class="control">
                        <button class="button is-link" type="submit">Submit</button>
                    </div>
                    <div class="control">
                        <button class="button is-link is-light">Cancel</button>
                    </div>
                </div>

            </form>

橡树服务器说我没有请求正文。 chrome 开发工具说我没有任何表单数据。

谁能明白为什么这个表单会在没有表单数据的情况下发布?

Request URL: https://localhost:8000/signup
Request Method: POST
Status Code: 200 OK
Remote Address: [::1]:8000
Referrer Policy: strict-origin-when-cross-origin

【问题讨论】:

    标签: html forms http http-post


    【解决方案1】:

    为您的&lt;input&gt; 元素指定name 属性,以便它本身和与之关联的值可以作为名称-值对发送。

    尝试像这样定义&lt;input&gt; 元素:

    <input name= "text-input" class="input" type="text" placeholder="Text input" value="joe">
    

    所以当输入为例如“myText”(为演示目的而缩短)时,请求将如下所示:

    Request URL: https://localhost:8000/signup 
    Request Method: POST
    
    text-input=myText
    

    MDN docs provide some insight 也是如此,您可能需要访问以了解清楚。

    【讨论】:

      猜你喜欢
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      • 2018-08-30
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 2016-05-28
      • 1970-01-01
      相关资源
      最近更新 更多