I'm making an click event in which I send the id
of the employee. I can see the value using console.log()
; the employee id is getting shown, but I keep getting an index :id error.
<input type="button" class="btn btn-primary" value="Appointment Letter" onclick="downloadempappointmentletter('<?php echo $data->employee_id;?>')">
function downloadempappointmentletter(id) {
$.ajax({
type: 'POST',
url: "<?php echo base_url(); ?>Admin/Employee/downloadappointmentletter",
data: { id: id },
success: function (data) {
console.log(data);
}
});
}
public function downloadappointmentletter()
{
$empid = $_POST['id'];
}
I keep getting error:
undefined index :id
However when I echo $data->employee_id;
it shows 1 etc. What am I missing?