<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把它帶到文件位置我假設它是從文件系統運行而不是通過服務器 –