为什么存在,而不是方法类型 get 的表单提交?

发布于 2024-10-01 05:43:25 字数 331 浏览 5 评论 0原文

我只是好奇为什么 HTML 有一个锚标记用于专门执行 GET 请求而无法更改 HTTP 请求类型,或者为什么不使用表单提交约定,因为无论如何我们都可能有 get-variables 的可能性。

更有趣的是锚标记如何链接到同一页面的#id 部分。

有充分的理由吗,还是这只是教条主义的残余?

编辑:我不是在问他们做什么,我是在质疑锚标记和表单提交的约定。

为什么它不是一个涵盖这些基础的 HTTP 请求元素,并且默认为 GET ,所以它可以与链接一起使用吗?为什么决定召开这个大会?我是说这对我来说听起来很疯狂,我想知道这个决定的决定是否有任何理由。

I'm simply curious, as to why HTML has an anchor tag used to preform GET requests specifically without ability to change HTTP request type, or otherwise why not use the form submission convention, as we may have the possibility of get-variables anyway.

More interesting is how anchor tags link to #id sections of the same page.

Is there a good reason, or is this simply a dogmatic leftover?

Edit: I'm not asking about what they do, I'm questioning the convention of anchor tags and form submissions.

Why isn't it an HTTP request element that covers these bases, and defaults as GET, so it works with a link? Why was this convention decided upon. I'm saying it sounds insane to me and I want to know if there's any justification from when it was decided upon.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

对风讲故事 2024-10-08 05:43:25

锚点连接两个文档或文档的一部分,即当前文档和引用文档。但表格则不然。表单用于发送查询。就是这样。

An anchor connects two documents or parts of documents, i.e. the current and the referenced. But a form doesn’t. A form is for sending queries. That’s it.

°如果伤别离去 2024-10-08 05:43:25

The <a> tag is used to navigate from one page to another, which requires GET requests only. And because URLs support the possibility of sending variables (e.g. ?a=b) there is absolutely no need for a more complex tag.

Obviously, the <a> tag is an inline element, while the <form> tag is a block element. So you could conclude that anchor tags need to be simple, while form elements may be a bit more complex.

血之狂魔 2024-10-08 05:43:25

使用 get 更容易,因为您可以使用一个字符串执行整个操作,无需其他标签。它简短而简单,对于大多数参数传递和导航应用程序来说它是完美的。

POST 用于表单和文件附件。 GET 的大小有限制,而 POST 则没有。

更有趣的是锚标记如何
链接到同一页面的 #id 部分。

是否有充分的理由,或者是这个
只是教条主义的残余?

不,哈希 URL 仍然有用,并且是页内导航的良好非 JavaScript 后备方案。哈希 URL 现在被提升到一个新的水平,以便维护基于 AJAX 的页面的状态和书签。

It's easier to use get because you can perform the entire action with one string and no additional tags. It's short and simple and for most parameter-passing and navigation applications it's perfect.

POST is for forms and file attachments. GET is limited in size, POST is not.

More interesting is how anchor tags
link to #id sections of the same page.

Is there a good reason, or is this
simply a dogmatic leftover?

No, hash URLS are still useful and are a good non-javascript fallback for in-page navigation. Hash URLs are now being taken to the next level in order to maintain state and bookmarking of AJAX-based pages.

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