【发布时间】:2017-12-18 05:23:07
【问题描述】:
我尝试使用 ajax 在 bootstrap 选择选项上显示数据,但我运行数据后不想出现什么问题?
function get_value() {
$id = 5;
$q = $this->db->select('*')
->from('tbl_v')
->where('id', $id)
->order_by('id', 'ASC')
->get();
$result = $q->result();
echo json_encode($result );
}
$(".change").change(function(){
var value=$(this).val();
if(value>0){
$.ajax({
url: base_url+"get_value",
type:"POST",
dataType: 'json',
cache: false,
data:{id:value},
success: function(respond){
$(".get-change").html(respond).selectpicker('refresh');
}
})
}
});
【问题讨论】:
-
尝试使用此代码查看值 Alert(JSON.Stringify($(this).val()))。
-
别忘了
json_encode()你的$q->result() -
对不起,我更新了我的问题,
标签: ajax twitter-bootstrap codeigniter