查看页面:
<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: "html",
success: function(data){
$('#dispach_challan_no').html(data);
},
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();
}
答案 0 :(得分:0)
只需从您的回复中获取ID。
尝试这样
form_with
或
remote
答案 1 :(得分:0)
请使用此-
查看页面-
<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);
}