I post data to a PHP file. The POST and GET data is empty, but php://input perfectly shows the posted data.
How is this possible? And what can I do to check / fix this?
This is my code:
const myJSON = JSON.stringify(data);
let result = myJSON.replace("[{","{");
result = result.replace("}]","}");
result = result.replace(/},{/g,",");
var user = '{{ Auth::user()->name }}';
var l = document.getElementById("languages");
var langcode = l.value;
var params = 'user='+user+'&lang='+langcode+'&data='+result;
var url = "/public/test.php";
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.send(params);