I'm trying to send a post request like this:
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);
I'm using an Apache Server, and this is my .htaccess
file
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>
Whenever I send the request I get this error:
Failed to load resource: the server responded with a status of 400 (Bad Request)
enter code here
Why is this happening? I have used GET requests with Steam and they work fine, put this POST request doesn't seem to be working.
EDIT: This is steamcommunity.com's
robot.txt
file:
User-agent: *
Disallow: /actions/
Disallow: /linkfilter/
Host: steamcommunity.com
It says Disallow: /actions/
, so is this the reason why I'm getting a 400
error?
Did you use setRequestHeader
?
xhr.open("POST", "/steamapi/actions/RemoveFriendAjax", false);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.