ajax中文亂碼問題在中文中經常會出現這種問題,其實只要稍加注意就不會出現ajax中文亂碼這回事情了,注意前后臺編碼一致.你用的是中文.而ajax傳輸數據的時候用的是utf-8 ,還有對ajax get方法時最好escape 或urlcode,
復制代碼 代碼如下:
<%@ page contenttype="text/html;charset=gb2312%>
復制代碼 代碼如下:
response.setcontenttype("text/html;charset=gb2312");
request.setcharacterencoding("gb2312");
復制代碼 代碼如下:
response.setcontenttype("text/html;charset=gb2312");
request.setcharacterencoding("gb2312");
復制代碼 代碼如下:
string param = request.getparamter("param");
param = new string(param.getbytes("iso-8859-1"),"gb2312");
復制代碼 代碼如下:
<script>
var oxmlhttp = new activexobject( "microsoft.xmlhttp ");
oxmlhttp.open( "get ", "http://dotnet.aspx.cc/content.aspx ", false);
oxmlhttp.send()
var ostream = new activexobject( "adodb.stream ");
if(ostream == null)
alert( "您的機器不支持adodb.stream. ")
else
{
ostream.type=1;
ostream.mode=3;
ostream.open() ;
ostream.write(oxmlhttp.responsebody);
ostream.position= 0;
ostream.type= 2;
ostream.charset= "gb2312 ";
var result= ostream.readtext();
ostream.close();
ostream = null;
alert( result);
}
</script>
復制代碼 代碼如下:
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
復制代碼 代碼如下:
response.setheader("content-type","text/html; charset=gb2312");
復制代碼 代碼如下:
string username = new string(request.getparameter("username").getbytes("iso8859_1"),"gb2312");
復制代碼 代碼如下:
string username = new string(request.getparameter("username").getbytes("iso8859_1"),"gb2312");
復制代碼 代碼如下:
string username = new string(request.getparameter("username").getbytes("iso8859_1"),"utf-8");
新聞熱點
疑難解答
圖片精選