简体   繁体   English

有没有办法代表浏览器发出 POST 请求

[英]Is there a way to make a POST request on behalf of browser

I need to make a POST request with JavaScript but in a way that browser would proceed it.我需要使用 JavaScript 发出 POST 请求,但浏览器会以某种方式进行处理。 So I need to make it as if any form has been submitted on page, so browser would deal with server response not me in JavaScript code.所以我需要让它好像在页面上提交了任何表单,所以浏览器将处理服务器响应而不是我在 JavaScript 代码中。 I only need to attach body and specify URL for request and then I want browser to do the rest. Is there any way to do it except for creating fake form with JS and submitting it?我只需要附加正文并为请求指定 URL 然后我希望浏览器执行 rest。除了用 JS 创建假表单并提交之外还有什么办法吗?

I've ended up with creating fake form and submitting it.我最终创建了伪造的表格并提交了它。 It doesn't seems too complex, although not particularly elegant.它看起来并不太复杂,虽然不是特别优雅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM