Hi, I have this problem, I have a canvas which serves as a signature for documents that are sent to the same form where you are with phpself
, but at the time of doing the conversion in ajax to send it as string of image , nothing brings me the variable that I receive by POST, in simple words. this is the code:
AJAX:
jQuery(document).ready(function($){
var canvas = document.getElementById("firma");
var signaturePad = new SignaturePad(canvas);
$('#limpiar').on('click', function(){
signaturePad.clear();
});
$('.enviado').on('click', function(){
var dataURI = signaturePad.toDataURL("image/jpg")
alert(dataURI);
$.ajax({
method: "post",
url: "cortesias_view.php",
data: { firma: dataURI }
});
});
});
PHP form}:
<form id="formu" name="formu" method="post" action="<?php $_SERVER['PHP_SELF']?>">
Reception of POST variables:
if (!empty($_POST['enviado'])) {
$fecha = $_POST['theDate'];
$folio = $_POST['folio'];
$concepto = $_POST['concepto'];
$clasificacion=$_POST['clasicacion'];
$lugar=$_POST['lugar'];
$firma=$_POST['firma'];
echo 'firma: '.$firma;
$solicitante = $_POST['solicitante'];
}
Submit button:
<td><input type="submit" name="enviado" class="enviado" id="enviado" value="GUARDAR" class="boton" /></td>
Canvas HTML:
<canvas id="firma" class="firma" name="firma" width="150" height="50" style="border: 2px solid #000;"></canvas>