I want to send to a php file (which is in charge of acting like a server) some form variables and a canvas image using the method POST. Everything must be done by pressing a button. Here is my JS code snippet which only works for form variables but not for the canvas pic.
var create = document.getElementById('create');
create.addEventListener('click', function () {
var dataURL = canvas.toDataURL();
$.ajax({
type: "POST",
url: "parameters.php",
data: {
imgBase64: dataURL
}
});
}
Does anyone know why the canvas picture is not sent to the parameters.php file?