gpt4 book ai didi

php - 我想用ajax在文本框中显示id

转载 作者:行者123 更新时间:2023-11-29 16:44:29 25 4
gpt4 key购买 nike

查看页面:

<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();
}

Controller

public function fetchId()
{
$modelResult = $this->dispatchModel->fetchId();
}

1

最佳答案

请使用这个--

查看页面 -

<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();
}

Controller --

public function fetchId()
{
$modelResult = $this->dispatchModel->fetchId();
echo json_encode($modelResult);
}

关于php - 我想用ajax在文本框中显示id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53166914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com