【发布时间】:2012-09-14 21:24:20
【问题描述】:
我正在使用此代码从国家代码呼叫城市
<script>
function getXMLHTTP() {
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getCity(strURL) {
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('citydiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
但结果不幸显示在?????????
编码有问题
我的主要编码是
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
我的问题是如何在函数中设置编码以使用我的主编码加载
此链接包含与我相同的问题
【问题讨论】:
-
您在这里尝试支持哪些浏览器版本?需要支持IE6还是IE5.5?对 xmlhttp 的三向检查看起来像是在尝试支持一些非常旧的 IE 版本。如果您不支持这些版本,其中很多可能是不必要的。 (坦率地说,如果你有选择,我不会支持他们)
-
我只需要 FF 和 Chrome 和 Safari 但我该如何解决编码问题
标签: ajax