我无法从品牌和模型概念中获取API数据..在变换品牌上它应该从API中获取模型详细信息并在模型选择中显示

问题描述 投票:0回答:1

我曾使用codeigniter为我们从这个项目获得品牌

<select name="brandId" onchange="getModel(this.value);" required>
  <option value ="2">select</option>
  <?php foreach($masterlist['result']['brand'] as $key => $value) { ?>                                                          
    <option value= "<?php  echo $value['brand_id'] ;?>">
    <?php  echo $value['brand_name'] ;?></option>
  <?php } ?>
</select>

这就是功能

 function getModel(value){
    $.ajax({ 
          type: "GET",
           dataType: "json",
           url: "<?php echo site_url().'/welcome/getvehicleModel/'?>"
           data: data,
           success: function(response){  
            console.log(response);              
                }
        });
    }
php codeigniter
1个回答
0
投票

成功:功能(响应){

                console.log(response.result[0]['model_id']);
                if(response.result){
                for(i=0;i<response.result.length;i++){

                var opt = new Option(response.result[i]['model_name'],response.result[i]['model_id']);
                    $("#model").append(opt);

                    }
                }
© www.soinside.com 2019 - 2024. All rights reserved.