Пожалуйста, используйте это -
Просмотр страницы -
<label >Challan No.</label>
<input type="text" class="form-control" id="dispach_challan_no" name="dispach_challan_no" placeholder="Enter Challan No">
<script>
$.ajax({
url :"<?php echo base_url();>booking/dispatch_challan/DispatchChallanController/fetchId",
type:"GET",
dataType: "JSON",
success: function(data){
$('#dispach_challan_no').val(data[0]['id']);
},
error:function(data){
alert("error message"+data);
},async:false,
});
</script>
Модель -
public function fetchId(){
$query= $this->db->select('*')->from('bilty')->get();
return $query->result_array();
}
Контроллер -
public function fetchId()
{
$modelResult = $this->dispatchModel->fetchId();
echo json_encode($modelResult);
}