这是在我的.erb文件中:
<form method="post" action="/login" id="login" enctype="text/plain">
Username: <input type="text" id="username" placeholder="Enter username here">
Password: <input type="password" id="password" placeholder="Enter password here">
<%= @error (will display if wrong) %>
<input TYPE="button" VALUE="Submit" />
</form>这是在我的.rb文件中:
post '/login' do
#connects to database
if #connection successful
# does something
else
#do something else
end
end但是,当我尝试单击“提交”按钮登录时,什么也没有发生。最初,我连接到数据库并检查信息,但在那之后,我只是尝试将错误消息设置为某个值,但即使这样也不起作用。我知道我漏掉了一些愚蠢的东西。哪一块不在那里?(将Postgres与Eruby结合使用,并在Heroku上运行。)
发布于 2014-02-28 00:35:32
您使用的是input的button type,文档中说:
元素表示没有默认行为的按钮。
当你想把一些input行为附加到一个按钮上时,通常会用到这种类型的javascript控件。为了提交表单,您需要type=submit
输入元素表示一个按钮,当该按钮被激活时,将提交表单。
因此,在您的Erb文件中,更改以下行:
<input TYPE="button" VALUE="Submit" />至
<input TYPE="submit" VALUE="Submit" />https://stackoverflow.com/questions/22073144
复制相似问题