我们提交了一个 javascript/jQuery 表单:
var form = jQuery("<form action='http://ourdomain.com/api/setter' method='post' target='response_frame'><input type='text' name='c' value='aaaa'></form>").appendTo(document.body);
form.submit();
相应的请求在 IIS 日志中显示为 GET(并且缺少“c”值,因为它应该位于正文中)。有任何关于 POST 如何变成 GET 的提示吗?
我无法在本地重现它,它可以按预期使用 POST,它仅显示在生产中的 IIS 日志中。
最佳答案
发生这种情况是因为 IIS 在 URL 中添加了尾部斜杠,这会导致 301 重定向。因此,POST
变为GET
。作为解决方案,请尝试在表单操作中添加尾部斜杠:
var form = jQuery("<form action='http://ourdomain.com/api/setter/' method='post' target='response_frame'><input type='text' name='c' value='aaaa'></form>").appendTo(document.body);
form.submit();
希望这对您有帮助。
关于javascript - 表单 POST 提交请求显示为 get 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38469961/