简体   繁体   中英

cascading drop-down not populating in IE 9 (Codeigniter)

I created a cascading drop-down in Codeigniter, but the second drop-down is not populating in IE 9 and IE 8. Here's the relevant controller:

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;
    }

Here's the relevant bit from my view:

<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>

Can anyone tell me why it might not be working correctly in IE 9 and 8?

由于'class'是javascript中的保留关键字,因此您应将其更改为class_name:

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

This can be fixed on IE 9 by changing the settings of IE 9 to compatible mode. (IE 9 ->Settings -> F12 Developer Tools -> Browse Mode -> Then Select IE 9 Compatibility). It seems to work for our ADF Apps with cascaded dropdowns

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM