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

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.

dongpiao1983
dongpiao1983 我想是的。我主要在用户滚动浏览页面中的某个点(滚动链接定位)时显示某些内容的网站上看到“滚动链接定位效果”警告。尝试删除/禁用该按钮的JS,看看是否仍然出现该警告。这可能不会修复你的“结果没有出现在控制台中”错误。
一年多之前 回复
dongwo5449
dongwo5449 是的,我有那种按钮,是那个按钮导致麻烦?
一年多之前 回复
dongwu1992
dongwu1992 不确定警告消息是否与任何代码相关。您的页面上有“返回顶部”按钮/链接吗?
一年多之前 回复

1个回答



ambildata()</ code>函数放入&lt; select&gt; </ code>标记中< 代码>&lt;选项&gt; </ code> </ p>

 &lt; select name =“inputBody”id =“inputBody”class =“form-control”required =“required”onchange  =“ambildata(this.value)”&gt; 
</ code> </ pre>

第二件事在Ajax调用中有些变化</ p>

 <  code> url:'&lt;?php echo base_url(“Repairpaint / chained”);  ?&gt;'
</ code> </ pre>

OR </ p>

  url:'&lt;?php echo base_url();  ?&GT;”  +'Repairpaint / chained'; 
</ code> </ pre>

发送数据</ p>

  data:{'input':x} \  n </ code> </ pre> 
</ div>

展开原文

原文

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 }

duanjianxi8439
duanjianxi8439 尝试在Ajax调用中使用jsonp。 它将绕过同源政策。 阅读更多learn.jquery.com/ajax/working-with-jsonp
一年多之前 回复
donglou1866
donglou1866 它在本地服务器上
一年多之前 回复
dpnfxk251524
dpnfxk251524 它在本地或实时服务器上?
一年多之前 回复
douxin1163
douxin1163 Hai,我已经尝试了你的解决方案,问题已经消失,但现在我面临另一个问题,即说Cross-Origin Request被阻止,我不知道这是什么意思。 你知道那是什么吗? 谢谢
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问