I am sending a canvas image using ajax to a php page that will catch it. Console tells me it is failing every time and not even sending. I have double checked everything and still am not seeing the issue. I finally walked away from it for a week and came back to it and for the past few hours I am still not seeing the issue. What am I over looking? The jQuery version on the server is 2.2.4
var dataURL = canvas.toDataURL();
var pngImage = new FormData();
pngImage.append('Image', dataURL);
$.ajax({
url: 'upload.php',
method: 'POST',
dataType : 'text',
data: pngImage,
cache: false,
contentType: false,
processData: false,
success: function(data) {
console.log("sucessful send:");
console.log(data);
},
error: function() {
console.log('failed');
}
});
UPDATE: When using
var Grabcanvas = document.getElementById("signature");
var ImgData = document.getElementById("Image").value = Grabcanvas.toDataURL();
var pngImage = new FormData();
pngImage.append('Image', $('#signature')[0].toDataURL());
console.log(ImgData);
console.log(pngImage);
$.ajax({
url: 'upload.php',
type: 'POST',
dataType : 'text',
data: pngImage,
cache: false,
contentType: false,
processData: false,
success: function(data) {
console.log("sucessful send:");
console.log(data);
},
error: function(d) {
console.log('error');
console.log(d);
console.log(d.responseText);
}
var ImgData
returns the proper canvas data however var pngImage
is empty and returns as FormData { }
in the console.