0

I have an XMLHttpRequest with which I want to send a string, but it receives array(0) in the alert, before with x-www-form-urlencoded and without stringify it worked but it didn't receive the data in the post, but now not even that , but I have read that it is how it should be done to send a string, then I leave you the JS and the .php so you can see it, thank you very much in advance :)

var img = chartR.toDataURL("image/png");
document.getElementById('base64').value = img;
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (xhttp.readyState == XMLHttpRequest.DONE) {
        alert(xhttp.responseText);
    }
}
xhttp.open("POST", base_url_admin+"record/reporte", true);
xhttp.setRequestHeader("Content-type", "application/json");
let data = JSON.stringify({"resultChartImg": img});
xhttp.send(data);
$resultChartImg = $_POST;
var_dump($resultChartImg);exit();
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

0 Answers0