我有锚标记,如果我点击锚标记我想在数据库中的该页面的一个div中显示带有该ID的数字。
我的观点
<div class="col-sm-4 text-center">
<a href="" onClick="return getVotes(userRef);" ><i class="fa fa-phone margin-right-10"></i> Call Doctor</a>
</div>
<div id="content"></div>
<script>
$(document).ready(function(){
alert("gfdfg");
function getVotes(userRef){
$.ajax({
type: 'get',
url: 'http://localhost/web/view-number',
data: 'userRef=' + userRef,
success: function(data) {
//alert(data);
$('#content').html(data);
}
});
}
});
</script>
控制器:
function viewNumber($userRef = NULL){
//echo "fdsfd";exit;
$this->load->model('DoctorSearch');
$result = $this->DoctorSearch->getNumber($userRef);
if ($result) {
$data['records'] = $result;
//echo '<pre>'; print_r($data['records']); die('test');
}
$this->load->view('pages/view-number', $data);
}
模型:
public function getNumber($userRef = NULL) {
//print_r($userRef); die('test');
$this->db->select('us.userRef,us.medicalRegNo');
$this->db->from('tab_usersprofile as us');
$this->db->where('us.userRef', '3mrTIaKjHAZ2BC7b');
$query = $this->db->get();
//echo $this->db->last_query(); die('test');
$result = $query->result();
return $result;
}
怎么做,没有什么是打电话检查我的代码并给出正确的inout