我嘗試使用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()' –
對不起,我正在更新我的問題, –