duanmen1887 2019-04-09 06:02 采纳率: 0%
浏览 60

在制作链式下拉列表时遇到滚动链接的问题

I'm facing scroll-linked trouble while making chained dropdown.

I'm using php as programming language and codeigniter as the framework, here are the codes

View Codes

     <div class="form-row">
       <div class="col-md-4">
         <label for="inputBody">Body Number</label>
         <select name="inputBody" id="inputBody" class="form-control" required="required">
            <?php foreach ($body as $bd) { ?>
              <option value="<?php echo $bd->bodynumkids ?>" onchange="ambildata('+<?php echo $bd->bodynumkids ?>+');"><?php echo $bd->bodynumkids ?></option>
            <?php } ?>
          </select>
        </div>
        <div class="col-md-6">
           <label for="inputKiddie">Kiddies Name</label>
           <input type="text" name="inputKiddie" id="inputKiddie" class="form-control" placeholder="ex. Super Cop" required="required">
        </div>
        <script type="text/javascript">
           function ambildata(x) {
             $.ajax({
                type:'POST',
                data :'input='+x,
                url :'<?php echo base_url()."Repairpaint/chained" ?>',
                dataType: 'json',
                success: function(data){
                   console.log(data);
                }
               })
              }
          </script>
       </div>

Controller Codes

public function chained()
    {
        $dataKiddie = $this->input->post('input');
        $where = array('bodynumkids'=> $dataKiddie);
        $namakiddie = $this->Model_repairpaint->chaincb('kiddiejadi', $where)->result();
        echo json_encode($namakiddie);
    }

The result wasn't appear in console, only these warning that appear

This site appears to use a scroll-linked positioning effect. This may not work well with asynchronous panning; see https://developer.mozilla.org/docs/Mozilla/Performance/ScrollLinkedEffects for further details and to join the discussion on related tools and features!

What expected is the data from database appear in console when I click the dropdown. Can anyone here tell me the solution? Thank you before, for helping me.

  • 写回答

1条回答 默认 最新

  • dtot74529 2019-04-09 06:08
    关注

    Put ambildata()function in <select> tag not in <option>

    <select name="inputBody" id="inputBody" class="form-control" required="required" onchange="ambildata(this.value)">
    

    And the second thing some changing in the Ajax call

    url : '<?php echo base_url("Repairpaint/chained"); ?>'
    

    OR

    url : '<?php echo base_url(); ?>' + 'Repairpaint/chained';
    

    Sending Data

    data : { 'input': x }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?