为什么从本地存储呈现的HTML文件不会向服务器发送请求?
具有以下form
包含a 提交按钮:
<form action="/process" method="post">
<p><input type="submit" value="Submit"></p>
</form>
我正在检查一个网页,除其他内容外,该网页 当我单击提交按钮时成功处理我的发布
请求并发送响应。
我将此页面的源HTML保存到计算机上的本地文件,然后用浏览器打开本地文件。浏览器像原始网页一样显示网页。
但是,当我单击提交按钮时,我会收到一个错误:
Your file couldn’t be accessed
It may have been moved, edited, or deleted.
ERR_FILE_NOT_FOUND
Asaik的原因是,浏览器在我的计算机上搜索/process
文件,但找不到一。
问题:为什么浏览器在我的本地计算机上搜索此文件,而不是向远程服务器发送请求?
I am inspecting a webpage, which apart from other content has the following form
containing a Submit button:
<form action="/process" method="post">
<p><input type="submit" value="Submit"></p>
</form>
When I click the Submit button, the website successfully processes my post
request and sends a response.
I saved the source html of this page to a local file on my computer, then I opened the local file with a browser. The browser displays the webpage just like the original one.
However, when I click the Submit button, I get an error:
Your file couldn’t be accessed
It may have been moved, edited, or deleted.
ERR_FILE_NOT_FOUND
the reason, ASAIK, is that the browser searches for a /process
file on my computer and does not find one.
QUESTION: Why does the browser search for this file on my local computer, rather than sending a request to a remote server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
action
属性需要一个url来发送数据。/process
正在指示浏览器将数据发送到您的本地计算机,因为这是表单的来源。这是相对于形式提供的位置。显然,正如您推测的那样,要纠正这一点,就是提供指向您在线服务器的适当URL。
The
action
attribute requires a URL for where to send the data./process
is directing the browser to send the data to your local computer because that is where the form came from. It's relative to where the form is served from.To correct this, obviously and as you surmised, is to supply a proper URL that points to your online server.