Not sure why I can't get the value to pass as paramater to my stored procedure
<button data-id="'.$row['id'].'" data-name="'.$row['template_number'].'" value="'.$row['boardname'].'" class="button temp-clone btn-clone btn btn-primary btn-icon" title="Clone '.$row['boardname'].' board only." data-original-title="Clone '.$row['boardname'].' only."><i class="typcn typcn-tabs-outline"></i></button>
Onload Event:
$("body").on("click",".btn-clone", function TemplateClone() {
var name = $(this).data('name');
$.ajax({
type: "POST",
url: "include/getData_TemplatesClone.php",
data: {name: name},
success: function(data){
swal({
position: 'top-end',
icon: 'success',
title: 'The template '+ name +' was cloned successfully',
showConfirmButton: false,
timer: 2500
})
}
});
});
Custom page called getData_TemplatesClone.php
<?php
include ("dbcommon.php");
$region = $_SESSION["region"];
$userid = $_SESSION["UserID"];
if(isset($_POST['name'])){
$sql = "CALL todoboards_templateClone('".$_POST['name']."', '".$userid."', '".$region."')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
$conn->close();
}
?>
Any help appreciated :)