IE 9中没有填充的级联下拉列表(Codeigniter)

时间:2015-01-19 12:11:12

标签: javascript php ajax codeigniter internet-explorer

我在Codeigniter中创建了一个级联下拉列表,但第二个下拉列表没有在IE 9和IE 8中填充。这是相关的控制器:

public function buildDropEquipment($class)
    // This builds the dropdown field for newly added equipment
    {
         //set selected class id from POST
        $class = $this->input->post('class',TRUE);
        error_log("class variable: ".$class." \n", 3, "/Applications/MAMP/logs/php_error.log");


        //run the query for the cities we specified earlier
        $this->load->model('admin/MEquipment');
        $equipmentData['equipmentDrop']=$this->MEquipment->getEquipmentByClass($class);

       $output = null;

        foreach ($equipmentData['equipmentDrop']->result() as $row)
        {
            //here we build a dropdown item line for each query result
            $output .= "<option value='".$row->type."'>".$row->type."</option>";
        }

        echo  $output;
    }

以下是我认为的相关内容:

<script type="text/javascript">
            $(document).ready(function() { 


                $("#class").change(function(){
                     /*dropdown post */
                    $.ajax({
                    url:"<?php echo base_url(); ?>index.php?/admin/buildDropEquipment",    
                    data: {class: $(this).val()},
                    type: "POST",
                    success: function(data){

                        $("#type").html(data);
                    }                  
                    });  
                });
            });       
        </script>      
    </head>
    <body>

        <!--machine class dropdown-->
        <?php $classDrop = array('none' => 'Select One') + $classDrop; ?>
        <dl>
        <dt><strong><?php echo form_label('Equipment Class', 'class');?></strong></dt>
        <dd>
        <?php echo form_dropdown('class', $classDrop,'','class="required" id="class"');  ?>
        </dd>
        </dl>

        <!--equipment type dropdown-->
        <dl>
        <dt><strong><?php echo form_label('Equipment Type', 'type');?></strong></dt>
        <dd>
        <select name="type" id="type">
        <option value="">Select Equipment Class Above</option>
        </select>
        </dd>
        </dl>

有谁可以告诉我为什么它在IE 9和8中可能无法正常工作?

2 个答案:

答案 0 :(得分:0)

因为'class'是javascript中的保留关键字,所以您应该将其更改为class_name:

data: {class_name: $(this).val()},

答案 1 :(得分:0)

通过将IE 9的设置更改为兼容模式,可以在IE 9上修复此问题。 (IE 9 - &gt;设置 - &gt; F12开发人员工具 - &gt;浏览模式 - &gt;然后选择IE 9兼容性)。它似乎适用于具有级联下拉列表的ADF应用程序