Steam Post请求-加载资源失败:服务器的响应状态为400(错误请求)
Steam Post Request - Failed to load resource: the server responded with a status of 400 (Bad Request)
我正试图发送一个如下的张贴请求:
xhr.open("POST", "/steamapi/actions/RemoveFriendAjax", false);
var params = "sessionID="+session_id+"&steamid="+id;
xhr.onreadystatechange = function() {//Call a function when the state changes.
if(xhr.readyState == 4 && xhr.status == 200) {
alert(xhr.responseText);
}
}
xhr.send(params);
我使用的是Apache服务器,这是我的.htaccess
文件
RewriteEngine On
RewriteRule ^api/(.*)$ http://api.steampowered.com/$1 [P]
RewriteRule ^(.*)$ http://steamcommunity.com/$1 [P]
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
</IfModule>
每当我发送请求时,我都会收到以下错误:
Failed to load resource: the server responded with a status of 400 (Bad Request)
enter code here
为什么会发生这种情况?我在Steam中使用过GET请求,它们运行良好,所以这个POST请求似乎不起作用。
编辑:这是steamcommunity.com's
robot.txt
文件:
User-agent: *
Disallow: /actions/
Disallow: /linkfilter/
Host: steamcommunity.com
上面写着Disallow: /actions/
,这就是我出现400
错误的原因吗?
您使用setRequestHeader
了吗?
xhr.open("POST", "/steamapi/actions/RemoveFriendAjax", false);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
相关文章:
- 如何在具有某些 UI 视图的状态中管理工厂单个请求数据
- PhantomJs在控制台中发出http请求时不会返回任何状态
- ajax - 请求对象就绪状态不变
- 如何在alt.js中使用源成功请求后更新状态
- 如何使用scalajs-angular获取请求的http状态代码
- 所选列表元素不会保持选中状态(通过ajax请求更新后)
- 如何侦听跨域映像请求上的任何301/302重定向状态代码
- 浏览器状态栏:隐藏对特定网站的请求地址
- 使秒表在请求之间处于活动状态
- HTTP 状态 405 - 不支持请求方法“POST”(Spring MVC)
- 在运行应用并切换到路由或状态之前解决$http请求
- 获取在 <脚本 src >标记中添加的请求 URL 的状态
- 在状态更改时发送带有状态数据的 AJAX 请求
- xmlhttp请求状态302
- xmlhttp请求状态总是返回0
- http获取请求状态
- XMLHttpRequest:POST请求状态
- 用于显示异步请求状态的GUI组件
- 多个ajax请求状态
- 跟踪404错误页面或如何监控浏览器使用Javascript发出的http头请求状态