第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

數(shù)據(jù)不顯示 ajax 和 javascript ci

數(shù)據(jù)不顯示 ajax 和 javascript ci

慕桂英546537 2023-05-11 10:10:08
我想使用ajax,javascript snd CI php 選擇選項(xiàng) cat_id 在顯示相關(guān)子 cat-id 但不顯示數(shù)據(jù)后單擊。我正在測(cè)試警報(bào)數(shù)據(jù)顯示正常但沒(méi)有獲取 html 數(shù)據(jù)請(qǐng)分享寶貴的想法先生在這里分享代碼..阿賈克斯<script>     $(document).ready(function() {    $('#catid').on('click', function() {           var catid = $("#catid").val();           $.ajax({               url: "<?php echo base_url(); ?>get-form-detail",               type: "post",               data: "catid=" + catid,                success: function(response) {                   var res = JSON.parse(response);                                     for(i=0;i<res.length;i++)                            {                                                                //alert(res[i]['cat_title']);                                                                options +=  '<option value="' + res[i]['id'] + '">' + res[i]['cat_title'] + '</option>';                                $('#tbl').html(options);                             }                                                    }           });       });   });     </script>查看頁(yè)面<div class="row">                        <label class="col-sm-4 col-form-label text-right">Form Category : </label>                        <div class="col-sm-8">                           <div class="form-group">                              <select class="form-control" name="formID" id="formID">                                <div id="tbl"></div>                               </select>                           </div>                        </div>                     </div>
查看完整描述

2 回答

?
溫溫醬

TA貢獻(xiàn)1752條經(jīng)驗(yàn) 獲得超4個(gè)贊

將回調(diào)函數(shù)更改為


success: function(response) {

    let res = JSON.parse(response);

    let options = res.reduce((a,v)=>(`${a}<option value = "${v['id']}">${v['cat_title']}</option>`), '');

    $('#formID').html(options);                 

}

并使用此 html 代碼


<select class="form-control" name="formID" id="formID"></select>


查看完整回答
反對(duì) 回復(fù) 2023-05-11
?
四季花海

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超5個(gè)贊

我知道你如何使用變量選項(xiàng)添加更多項(xiàng)目,但我有另一個(gè)解決方案


替換您的代碼:


   var x = document.getElementById("yourSelectElementId");


   for(i=0;i<res.length;i++){

                                

        var option = document.createElement("option");


        option.text = res[i]['id'];

        option.value= res[i]['id'];


        x.add(option);

                              

    }


查看完整回答
反對(duì) 回復(fù) 2023-05-11
  • 2 回答
  • 0 關(guān)注
  • 171 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)