如何使用CodeIgniter访问基本站点URL ID并将其传递给控制器



我是Codeigniter

的新手

我想将基本URL ID访问到AJAX中,在内部,我还将另一个ID传递给CodeIgniter中的控制器。在控制器侧,我访问两个不同的ID一个site_url ID和另一个S_ID。

那么我该如何完成此任务?

Site URL

https://www.demoexample.com=?uid = 10

Ajax脚本

<script>
 $(document).ready(function(){
    $('#member_type').on('change',function(){
        var memId = $(this).val();
        if(memId!=''){
                       $.ajax({
                               url: "<?php echo site_url('index.php/template/vehicle/get_member_type')?>",
                               method:'POST',
                               data:'member_id='+memId, // here I want to access site_url id and s_id from drop-down id
                               success:function(data)
                               {
                                  $('#mid').html(data);
                               }
                             }); 
        }
        else{
           $('#mid').html('<option value="">Select sttxt_Standard first</option>'); 
        }
    });
});
</script>

控制器.php文件

   function show_vehicle_reg(){   
            $id=$this->input->post('id'); // access multiple id over here from ajax
        }
    }

预先感谢

ajax:
GET方法

$.ajax({
    beforeSend: function () {
    },
    complete: function () {
    },
    type: "GET",
    url: "<?php echo site_url('controller/cmethod/'.$s_id); ?>",
    success: function (data) {
    }
});

POST方法

$.ajax({
    beforeSend: function () {
    },
    complete: function () {
    },
    type: "POST",
    url: "<?php echo site_url('controller/cmethod'); ?>",
    data: ({member_id: memId}),
    success: function (data) {
    }
});

最新更新