为什么从本地存储呈现的HTML文件不会向服务器发送请求?

发布于 2025-02-12 02:24:44 字数 646 浏览 0 评论 0原文

具有以下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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

予囚 2025-02-19 02:24:44

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文