ajax返回中文乱码 10
<scriptlanguage="javascript">functiongetData(dataSource,divID){varXMLHttpRequestObjec...
<script language="javascript">
function getData(dataSource,divID)
{
var XMLHttpRequestObject=false;
if(window.XMLHttpRequest)
{
XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}
if(XMLHttpRequestObject)
{
var obj=document.getElementById(divID);
XMLHttpRequestObject.open("GET",dataSource);
XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XMLHttpRequestObject.onreadystatechange=function (){
if(XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200)
{
obj.innerHTML=XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
<body>
<input type="button" value="点击下载" onclick="getData('http://fw.qq.com/ipaddress','dataDiv')"/>
<div id="dataDiv">
<p>The fetch message will appear here</p>
</div>
</body>
Ajax 访问 'http://fw.qq.com/ipaddress' 得到返回至里包含的中文乱码 var IPData = new Array("116.236.130.106","","����",""); 这个怎么解决?
麻烦各位高手给看看! 展开
function getData(dataSource,divID)
{
var XMLHttpRequestObject=false;
if(window.XMLHttpRequest)
{
XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}
if(XMLHttpRequestObject)
{
var obj=document.getElementById(divID);
XMLHttpRequestObject.open("GET",dataSource);
XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XMLHttpRequestObject.onreadystatechange=function (){
if(XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200)
{
obj.innerHTML=XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
<body>
<input type="button" value="点击下载" onclick="getData('http://fw.qq.com/ipaddress','dataDiv')"/>
<div id="dataDiv">
<p>The fetch message will appear here</p>
</div>
</body>
Ajax 访问 'http://fw.qq.com/ipaddress' 得到返回至里包含的中文乱码 var IPData = new Array("116.236.130.106","","����",""); 这个怎么解决?
麻烦各位高手给看看! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询