Welcome Guest, Not a member yet? Register   Sign In
Ajax is not working well
#1

[eluser]afro[/eluser]
I have tried this but it is not working
Code:
$(document).ready(function() {
        
  staffid = prompt('Enter your Staff Id', $(this).find().html());
  if (staffid != null)
    {
function get_staff_data(staffid) {
  var p = {};
  p[staffid] = staffid
  $("input#staffid").load(index.php/user/load_staff_data,p,function(str){
});
}
}
            
            
});
My controller’s method is here below
Code:
function load_staff_data()
    {    
$ID = $_POST[staffid];  

   $this->load->model('user_model');
   $results = $this->user_model->get_staff_data($ID);
  
   $this->load->view('leave',$results);
}
the model is as follows
Code:
public function get_staff_data($ID)
{
$this->db->select('StaffId,StaffName, Department, LeaveBalance');
$this->db->where('StaffId', $staffid);
$query = $this->db->get('staff');
   $row = $query->row();
$results[record][$row->StaffName][StaffName] = $row->StaffName;
$results[record][$row->Department][Department] = $row->Department;
$results[record][$row->LeaveBalance][LeaveBalance] = $row->LeaveBalance;

return $results;



}

can someone help me out from here
#2

[eluser]alexaaaaaaaaaa[/eluser]
replace $_post with $this->input->post('staffid'); see if it works




Theme © iAndrew 2016 - Forum software by © MyBB