我正在使用 jquery 和 ASP,并且有一个 SQL 数据库,我使用函数 $.getJSON() 从中获取了一些西班牙语描述,其中包含“acentos”和“波浪线”(á、é、í、ó、ú、ñ , ETC。)。
Chrome 4 和 FireFox 运行良好。问题在于 IE8:对于一些特定的查询,它挂起而没有返回结果。如果我使用 IE 将所有“ó”替换为“o”,相同的结果集可以完美运行,所以我知道问题出在“acentos”(ó) 上。
我使用以下代码设置 ajax 调用:
$.ajaxSetup({'beforeSend' : function(xhr) {
if (xhr.overrideMimeType) {
//FF & Chrome
xhr.overrideMimeType('text/html; charset=iso-8859-1');
}else {
//IE8
//I tried everything here:
//xhr = new ActiveXObject("Microsoft.XMLHTTP");
//var obj = new ActiveXObject("MSXML2.XMLHTTP.3.0");
//xhr = new ActiveXObject("Msxml2.XMLHTTP");
//and get ERROR with IE8 in this line:
xhr.setRequestHeader('Content-type', 'text/html; charset=iso-8859-1');
}
}
});
然后,调用 getJSON() 来获取带有“acentos”的描述是这样的:
function showDialog(idCriterio, codAplica, descTema){
$("#dialog-modal").html("Buscando Datos...");//getting data...
$.getJSON("generarJSONTipos.asp", { idCriterio: idCriterio, codAplica: codAplica},
//callback function
function(data){
var textoDialogo;
textoDialogo= "";
$("#dialog-modal").html("<span class='tituloOpcion'>"+descTema+"</span><br><br>");
for(i=0;i<data.length;i++) {
//tomo el html actual
textoDialogo = $("#dialog-modal").html();
//le apendo la descripcion del elemento del array
$("#dialog-modal").html(textoDialogo + data[i].descripcion + "<br>");
}//end for
}//end callback
);//end getJSON
$("#dialog-modal").dialog({
height: 300,
width:450,
modal: true
});
$("#dialog-modal").dialog('open');
}
任何提示将不胜感激。我已经用谷歌搜索了好几天,没有得到这个问题的答案......:P
提前致谢, Ignacio(阿根廷拉普拉塔)