我的 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/