【发布时间】:2015-01-21 01:23:46
【问题描述】:
我正在尝试制作一个 NodeJS webapp,它在文本框中接受用户输入,然后根据单击的按钮将其用于两个功能之一(客户端)。我可以
1) 根据单击的按钮调用不同的操作
或
2)在帖子的正文中传递一些区分两个按钮的东西
我注意到,当按下不同的按钮时,使用以下代码对 console.log(req.body) 有两个不同的响应。 当我单击提交按钮时,我得到 “{句柄:'blahblahblah',hadunkachud:''}” 当我点击新鲜按钮时,我得到“{句柄:'blahblahblah',hingle:''}”
但是,我无法找到访问响应的唯一部分的方法,因为尝试访问 req.body 的第二个数组值什么也得不到
下面的代码在 Jade 中
extends layout
block content
h1= title
form#formEnterHandle(name="enterhandle",method="post",action="/showid")
input(type="text", placeholder="themirage", name="handle")
button(name = "hadunkachud", type="submit") submit
button(name = "hingle", type = "submit") fresh
【问题讨论】:
标签: javascript html node.js http