2009-11-07 11:04
IE6的怪模式,不知道为什么要让AJAX加的下拉框无法设置初始值(使用JQuery),觉得不是JQuery的问题,应该是归结到IE6的问题。
$.ajax({
type: "POST",
dataType: "json",
url: "../Ajax2.aspx?a=getCityList",
data: { "PId": pId },
success: function(cities) {
// remove all options first
$("#sCity option").remove();
$("<option>").attr("value", "0").text("请选择").appendTo("#sCity");
$.each(cities, function(entryIndex, entry) {
// add all cities related with the province
$("<option>").attr("value", entry.RegionId).text(entry.RegionName).appendTo("#sCity");
}
});
$("#sCity").val(data.CityName);
}
});
$("#sCity").val(data.CityName); 这行的设置,在IE6下无效~
在反复确认FF和IE7,8后,而且使用各种JQuery方式无效下,还是得从下拉框生成来解决。
// add all cities related with the province
if (entry.RegionName == data.CityName) {
$("<option>").attr("value", entry.RegionId).attr("selected", "selected").text(entry.RegionName).appendTo("#sCity");
} else {
$("<option>").attr("value", entry.RegionId).text(entry.RegionName).appendTo("#sCity");
}
});