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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题