你好,我使用Ajax在codeigniter中以json格式获取数据,所以当我打开模式时如何在文本框中获取数据
这是我的查询
public function assign_password()
{
$id = $this->input->POST('employee_id');
$query = $this->db->query("Select * from account_registration WHERE aid='$id'")->result_array();
echo json_encode($query);
}
这是我的AJAX通话:
$(document).on('click', '.assign_pass', function(){
var employee_id = $(this).attr("id");
$.ajax({
url:"<?php echo base_url('welcome/assign_password')?>",
method:"POST",
data:{employee_id:employee_id},
dataType:"json",
success:function(data){
var emp = $('#employee_name').val(data.firstname);
console.log(emp);
$('#add_data_Modal').modal('show');
}
});
});