Javascript 与node.js get/post混淆并尝试创建新页面
我一直在寻找如何做到这一点,整个晚上,但我不知道确切地搜索哪些术语,所以这是设置我回来了相当多 我试图在node.js应用程序中创建一个名为“/editor”的页面。我在我的索引页上创建了一个按钮,我想将其重定向到/editor。我也制作了一个editor.jade文件,但我不确定如何导航到它 在app.js中,我有:Javascript 与node.js get/post混淆并尝试创建新页面,javascript,node.js,web-applications,pug,Javascript,Node.js,Web Applications,Pug,我一直在寻找如何做到这一点,整个晚上,但我不知道确切地搜索哪些术语,所以这是设置我回来了相当多 我试图在node.js应用程序中创建一个名为“/editor”的页面。我在我的索引页上创建了一个按钮,我想将其重定向到/editor。我也制作了一个editor.jade文件,但我不确定如何导航到它 在app.js中,我有: app.get('/', routes.index); app.get('/game', routes.game); app.get('/getContents', routes
app.get('/', routes.index);
app.get('/game', routes.game);
app.get('/getContents', routes.getContents);
app.get('/editor', routes.editor);
app.post('/start', routes.start);
app.post('/quit', routes.quit);
app.post('/doAction', routes.doAction);
这应该是一个好机会吗?还是我感到困惑,而这实际上应该是一个帖子
在index.js中,我有:
function editor(req, res){
console.log("Hey Sarah!");
if(req.session.editor){
console.log("Hey Sarah!");
}
else{
console.log("Do you eve know what you're doing?");
}
}
exports.editor = editor;
在index.jade中,我有:
div.well
p Adventure Game Editor
div
form(action="/editor". method="post")
div.control-group.input-append
button(type ="editor") Editor
现在点击按钮只是将我重定向到/post?哪些显示无法获取/发布?在控制台中获取/发布?404 2ms浏览一下,您的
表单(action=“/editor.method=“post”)
似乎有一个句点而不是逗号(它们看起来非常相似,行为也非常不同)。我不确定杰德会怎么做,但这可能是你犯错误的原因。如果您想将发布的表单放到任何地方,您还需要一个app.post(“/editor”,FUNC_在此)
行。我会将按钮改为按钮(type=“submit”)
,因为编辑器
不是有效的html按钮类型。谢谢,我花了这么长时间研究代码,没有任何意义了,非常欢迎您;我自己也去过那里。正常情况下,这是我暂时摆脱它并清醒头脑的暗示,但有时我就是不能让它过去。很高兴我能帮忙!