【问题标题】:Node Express. Is there a way to send more complex data to the serverside with a form?节点快递。有没有办法通过表单将更复杂的数据发送到服务器端?
【发布时间】:2022-01-11 00:09:21
【问题描述】:

有没有办法向服务器端发送更多信息(例如对象)?

通过创建表单并添加输入

<form action="/home" method="POST">
    <input name="title">
    <input name="content">
</form>

我们得到

{
   title: "a",
   content: "something"
}

有没有办法做这样的事情:

{
   title: "a",
   content: {
               something: "f"
           }
}

【问题讨论】:

    标签: node.js express ejs


    【解决方案1】:

    提交表单时,您实际上是通过formdata 对象发送的,不,它不支持json 格式。

    【讨论】:

    • 那么我该如何存储和发送这种类型的数据呢?
    • 我建议展平数据。 contentSomething1、contentSomething2……等等。另一种方法是使用基于 REST 的 api。
    猜你喜欢
    • 2020-10-11
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-27
    • 2019-06-06
    • 2018-08-31
    相关资源
    最近更新 更多