0

i have a little program that converts a div in to a canvas and then saves like a photo in the server. The problem is the following: I'm sending with ajax a php data of the image, but i need to send an necessary id, this is the code:

function(){
html2canvas(document.getElementById("contenedor-pizarra-postural")).then(function (canvas) {
//Here is the ID thats i need to send
let idConsulta = document.getElementById("idConsulta").value;
var ajax = new XMLHttpRequest();
ajax.open("POST", "php/cargarPlanillas.php", true);
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//This is working only for the image data but i need to send the idConsulta variable :(
ajax.send("imagePostural=" + canvas.toDataURL("image/jpeg", 0.9))
})
ajax.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
}
};
});
}

0 Answers0