<form id = "myForm" action="localhost" method="get">
<input name="liftString" type="text">
<input type="submit">
</form>
单击“提交”按钮时,此表单不起作用。我没有重定向到localhost
。为什么action =“localhost”会导致在提交时没有做任何事情?
如果我将action
属性更改为"/localhost"
,它在本地运行表单时尝试将我带到file:///localhost?liftString=d
。
如果我将action
更改为"http://localhost"
,它正确地将我带到http://localhost/?liftString=f
。
发布的表单中发生了什么?为什么单击提交时表单无效?
澄清:我明白action="/localhost"
和action="https://localhost"
是怎么回事。我不明白的是为什么没有发生时,我有action="localhost"
。
由于/ localhost把它带到文件位置我假设它是从文件系统运行而不是通过服务器 –