简体   繁体   English

IE8中无法使用组合框

[英]not working combobox in IE8

I used tje following code to populate a combobox with data. 我使用以下代码在组合框中填充数据。 It works in Firefox and Google Chrome but not in IE8. 它适用于Firefox和Google Chrome,但不适用于IE8。

$.ajax({
    type: "POST", url:"reg/data/data.php", 
    data: {
        cat:"Y",
        //toUser: "4",
        // ignoreMessages:"1
    },
    success: function(data){
        $.each(data, function (i, elem) {
            $('#catogery').append( new Option(elem.id) );
            //console.log(elem);
        });              
    }
});  

PHP: PHP:

$result = mysql_query("SELECT DISTINCT CATCODE from subjectmaster");

$messages;

header('Content-type: application/json');

$return_arr = array(); 

while($row = mysql_fetch_array($result)) {
    $row_array['id']=$row[0];
    array_push($return_arr,$row_array);
}

echo json_encode($return_arr);

Remove the comma from after the cat: 从猫后去除逗号:

$.ajax({
type: "POST", url:"reg/data/data.php", 
data: {
    cat:"Y"

},
success: function(data){
    $.each(data, function (i, elem) {
        $('#catogery').append( new Option(elem.id) );
        //console.log(elem);
    });              
}

}); });

You have mentioned "," in data array and there is no element after that. 您在数据数组中提到了“,”,之后没有任何元素。 Remove "," and it should work. 删除“,”,它应该可以工作。

data: {
   cat:"Y", //<------Remove this comma
   //toUser: "4",
   // ignoreMessages:"1
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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