javascript - 将post表单值从jade提交到node js

标签 javascript node.js express pug jade4j

我的 Jade 模板上有这样的表格

  form(action='/scheduler/save/' + project.Id, method='post')
                div.form-group
                    label.control-label.col-md-2 RecurringPattern
                    div.col-md-10
                        div#RecurringPatternControl
                div.form-group
                    label.control-label.col-md-2 StartDate
                    div.col-md-3
                        //input#StartDate.form-control
                        input(id='StartDate', class='form-control', value='#{project.StartDate} ', enctype="application/x-www-form-urlencoded")
                div.form-group
                    div.col-md-offset-2.col-md-10
                        input(type="submit", value="Save").btn.btn-lg.btn-success

并且我想要来自 Node js中的输入值的StartDate,我从req.body获得了div#RecurringPatternControl,但是StartDate 我无法获取(( 我该如何解决这个问题?

最佳答案

我认为您的输入中需要一个“名称”属性,以便稍后能够检索它。 只需尝试添加类似

的内容
input(id='StartDate', name='startDate', class='form-control', value='#{project.StartDate} ', enctype="application/x-www-form-urlencoded"

它应该可以工作,如果没有尝试检查整个 POST header 以查看实际发生的情况(如果需要,可以将其发布到此处)

希望这有帮助!

关于javascript - 将post表单值从jade提交到node js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31262338/

相关文章:

javascript - 如何从 Ember.TextField 的 View 内切换 HTML 变量的值?

javascript - 按钮的 Scrollspy 偏移量

node.js - 如何在环回查询 Mongo 中获取聚合结果

node.js - 异步系列nodejs中的async foreach

node.js - 文件上传适用于 postman ,但不适用于 Angular2

javascript - 使用 cURL 返回 JSON 文件以使用 HighCharts 股票图表中的数据

javascript - 使用 Ajax 加载的动画内容

javascript - 如何使用 Bluebird promise Node 的 child_process.exec 和 child_process.execFile 函数?

javascript - Node.js 什么时候使用异步有意义?

html - 使用 NodeJS Express 时将表单数据插入 MySQL 数据库