当我在FF或Safari中运行这个JS时,它工作正常,但在IE中,我得到'optionValue‘为空或不是对象。
$(function() {
$('#selectBrand').change(function(){
$.getJSON('Scripts/ajax_busquedas.php', {idMarca : $(this).val() }, function(j) {
var options = '';
var i = '';
for (i = 0; i < j.length; i++) {
options += '<option value="' + j[i].optionValue +'">' + j[i].optionDisplay + '</option>';
}
$('#selectCategory').html(options);
$('#selectCategoy option:first').attr('selected', 'selected');
});
});
});对如何开始调试有什么想法吗?
谢谢,麦克斯
发布于 2009-08-27 22:57:15
检查你的Json,比如:
{"property1": 1, "property2":2,/*<-- see the extra 'trailing comma' */};在firefox,safari等中工作,但在IE中抛出错误。
发布于 2009-08-27 22:57:33
确保在JSON call的范围内定义optionValue和optionDisplay,或者将它们定义为全局变量,如下所示:
var optionValue = '';https://stackoverflow.com/questions/1344143
复制相似问题