Welcome Guest, Not a member yet? Register   Sign In
Codeigniter with Ajax to load data to view.
#3

[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


Messages In This Thread
Codeigniter with Ajax to load data to view. - by El Forum - 04-26-2011, 12:37 AM
Codeigniter with Ajax to load data to view. - by El Forum - 04-26-2011, 02:22 AM
Codeigniter with Ajax to load data to view. - by El Forum - 04-26-2011, 06:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB