Why is xmlhttp not sending parameters with method PUT, but everything is OK with the POST?

Subject. Code:

Cause: (if there is change PUT to POST, miraculously, all will go (all the parameters and the query itself), but with PUT, the options are ignored)
z = new Request("PUT", "/api/items/29", "name=" + encodeURIComponent("tested"), console.log);


Class
class Request {

 constructor(method, url, params, todo) {

 this.method = method;
 this.url = url;
 this.params = params;
 this.todo = todo;

 this.xmlhttp = null;

 try {
 this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
 try {
 this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (E) {
 this.xmlhttp = null;
}
}
 if (!this.xmlhttp && typeof XMLHttpRequest != 'undefined') {
 this.xmlhttp = new XMLHttpRequest();
}

 this.xmlhttp.open(this.method, this.url);
// this.xmlhttp.setRequestHeader('Content-Type', 'application/javascript');
 this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 this.xmlhttp.onreadystatechange = function () {
 if (this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200)
todo(this.xmlhttp.responseText);
}.bind(this);
this.xmlhttp.send(this.params);

}

 encodeParams(str) {

 str = str.split('&');

 return str;
}


}
March 12th 20 at 08:11
1 answer
March 12th 20 at 08:13
PUT forbidden in the configuration of the web server.

Find more questions by tags JavaScript