我用下面的代碼來填充數據組合框。它適用於Firefox和Google Chrome,但不適用於IE8。在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:
$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);
我取消註釋但仍然與以前一樣,爲什麼它只發生在IE –