如何将数据对象从jade传递到node.js
我正在尝试在我的服务器端JS 的jade 视图页面中构建一个数据对象。 它具有动态 html 创建功能,可以根据用户的需要插入输入框
function addDetail() {
var detailHtml =
'<tr><td width="55%"><input style="width:98%;" type="text" name="order.detail['+currentDetailCount+'].nam" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].prc" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].beg" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].cut" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].asb" /></td>' +
'<td width="49%"><input style="width:98%;"type="text" name="order.detail['+currentDetailCount+'].msc" /></td></tr>';
$('tbody#detailAddTbody').append(detailHtml);
currentDetailCount++;
}
,并且在正文中还有更多字段
select(name='order.cname',id='cname')
input(type='text', name='order.ordindate', id='ordindate')
似乎我无法从服务器端 app.js 检索“订单”对象。 如何将动态构建的数据对象传递到服务器端?
I'm trying to build a data object in jade view page to my server side JS.
it has dynamic html creation that inserts input boxes as user wants
function addDetail() {
var detailHtml =
'<tr><td width="55%"><input style="width:98%;" type="text" name="order.detail['+currentDetailCount+'].nam" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].prc" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].beg" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].cut" /></td>' +
'<td width="1%"><input type="checkbox" name="order.detail['+currentDetailCount+'].asb" /></td>' +
'<td width="49%"><input style="width:98%;"type="text" name="order.detail['+currentDetailCount+'].msc" /></td></tr>';
$('tbody#detailAddTbody').append(detailHtml);
currentDetailCount++;
}
and also have couple more fields in body
select(name='order.cname',id='cname')
input(type='text', name='order.ordindate', id='ordindate')
It seems like I can't retrieve 'order' object from my server side app.js.
How can I pass dynamically built data object to server side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用POST或GET方法或Ajax(客户端javascript)将数据发送到nodejs服务器端
在Jade中,它仅充当MVC模型中的视图,您不能将数据从jade传递到nodejs。
You should use POST or GET method or Ajax(client side javascript) to send data to the nodejs server side
In Jade, it is only act as view in MVC model, you can't pass data from jade to nodejs.