从网页发布原始表单数据
我想使用简单的 DHTML 发送原始发布数据,但不使用 XMLHttpRequest 对象。是否可以做到这一点,例如,通过将 HTML 表单元素的发布数据强制为任意字符串?
I would like to send raw post data using straightforward DHTML, but without using the XMLHttpRequest object. Is this possible to do this, for example, by forcing an HTML form element's post data to an arbitrary string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在发布表单之前,您可以动态地将 html 输入元素(带有值)添加到表单中,然后调用 form.sumbit()。但这仍然会刷新页面。
我知道在不刷新页面的情况下发布数据的唯一方法是使用 XMLHttpRequest 对象。使用 jQuery 使整个操作变得非常简单 http://api.jquery.com/jQuery.post/ ,所以我不确定为什么你不想使用ajax来完成这个?
Before you post the form, you could dynamically add html input elements (with values) to the form, and then call form.sumbit(). This will still refresh the page though.
The only way that I'm aware of to post data without refreshing the page is using the XMLHttpRequest object. Using jQuery makes this whole operation pretty trivial http://api.jquery.com/jQuery.post/ , so I'm not sure why you don't want to use ajax to accomplish this?
您可以轻松生成类似于 POST 请求的字符串。 POST 和 GET 之间没有太大区别。使用GET,参数添加在url后面。 POST 时,参数以相同的方式添加,但位于标头下方。
有关示例,请参阅 developers.sun.com。
You can easily generate a string that resembles a POST request. There is not much difference between a POST and a GET. Using GET, the parameters are added behind the url. When POSTing, the parameters are added in the same way, but below the headers.
See developers.sun.com for an example.