gpt4 book ai didi

javascript - 如何显示Jquery结果

转载 作者:行者123 更新时间:2023-12-03 07:02:11 25 4
gpt4 key购买 nike

我正在尝试将变量从 jquery 检索到我的 codeigniter Controller 。

我的 Jquery

    $(document).ready(function () {
$('#reservation').change(function(){
var ids = $('#reservation').val();
$.post ( "<?php echo base_url();?>index.php/sia/index/",
{ date_search:ids },
function(data){
//what i need to do ??
});
});
});

我的 HTML

       <div class="input-group margin col-lg-3 col-xs-6 pull-right">
<input type="text" class="form-control pull-right" readonly="readonly" placeholder="Cari Berdasarkan Tanggal" name="date_search" id="reservation" />
</div>

这是我的 Controller

     function index()
{
// How to retrieve date_search
$explode = explode('-',$date_search);
$start_date = inggris_date($explode[0]);
$end_date = inggris_date($explode[1]);
$data['master'] = $this->db->query("select status,b.Nip,b.positioncode,a.start_date,a.ApprovedBy,c.OutletCode,a.Approvedby,a.IdAttendanceA,a.Alokasi,a.keterangan,a.files,b.FullName
from Attendance_Alokasi a left join employee b on a.Nip = b.Nip
left join outlet c on b.OutletCode = c.OutletCode
where flag = '1' and (start_date >= '".$start_date."' and start_date <= '".$end_date."') and a.Nip = '".$Nip."'")->result();
$data['judul'] = "Sia";
$view = "sia/index";
$controller = "sia";
$this->get_view($data,$view,$controller);
}

如何在我的 Controller 中检索date_search:ids并执行echo

更新。

当我输入05/03/2016 - 05/03/2016后执行alert(ids)时,结果如下: enter image description here

最佳答案

这是你的 Controller

 function index()
{
$date_search = $this->input->post('date_search');
$explode = explode('-',$date_search);
$sd = trim($explode[0]);
$ed = trim($explode[1]);
$start_date = inggris_date($sd);
$end_date = inggris_date($ed);
$data['master'] = $this->db->query("select status,b.Nip,b.positioncode,a.start_date,a.ApprovedBy,c.OutletCode,a.Approvedby,a.IdAttendanceA,a.Alokasi,a.keterangan,a.files,b.FullName
from Attendance_Alokasi a left join employee b on a.Nip = b.Nip
left join outlet c on b.OutletCode = c.OutletCode
where flag = '1' and (start_date >= '".$start_date."' and start_date <= '".$end_date."') and a.Nip = '".$Nip."'")->result();
$data['judul'] = "Sia";
$view = "sia/index";
$controller = "sia";
$this->get_view($data,$view,$controller);
}

现在在客户端。以下将提醒您输入的 date_search

function(data){
//here you data is the return value from sia/index/`
alert(data);
});
...

关于javascript - 如何显示Jquery结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36994624/

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