我尝试使用ajax在引导选择选项上显示数据,但运行数据后不想出现什么问题?使用ajax值设置引导选定选项
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()' –
对不起,我正在更新我的问题, –