I'm sending an ajax "POST" in my php file. But the problem is the index of the POST is undefined.
This is my sample code in ajax.
$(".add-percentage").click(function(){
var percentage_id = $(this).data('landing_id-percentage');
$.ajax({
url: 'ajax/readPercentage.php',
type: 'POST',
data: { percentage_id : percentage_id },
success: function(data) {
alert(data);
},
error: function(request, status, error){
alert("Error!! "+error);
}
});
});
My php code having an undefined index POST..
if(isset($_POST['percentage_id'])){
$percentage_id = $_POST['percentage_id'];
$query = mysqli_query($conn, "SELECT * FROM percentage WHERE percentage.percentage_id = '$percentage_id'");
}else{
echo "Index is not properly set!";
}
I hope someone can help me. Thanks in advance.