天天看點

asp接收ajax亂碼_asp,jquery,ajax中文亂碼解決辦法

asp接收ajax亂碼_asp,jquery,ajax中文亂碼解決辦法

?绋?搴?浠g??

'涓?javascript涓???escape()绛???

Function VbsEscape(str)

dim i,s,c,a

s=""

For i=1 to Len(str)

c=Mid(str,i,1)

a=ASCW(c)

If (a>=48 and a<=57) or (a>=65 and a<=90) or (a>=97 and a<=122) Then

s = s & c

ElseIf InStr("@*_+-./",c)>0 Then

s = s & c

ElseIf a>0 and a<16 Then

s = s & "%0" & Hex(a)

ElseIf a>=16 and a<256 Then

s = s & "%" & Hex(a)

Else

s = s & "%u" & Hex(a)

End If

Next

VbsEscape=s

End Function

'涓?javascript涓???unescape()绛???

Function VbsUnEscape(str)

Dim x

x=InStr(str,"%")

Do While x>0

VbsUnEscape=VbsUnEscape&Mid(str,1,x-1)

If LCase(Mid(str,x+1,1))="u" Then

VbsUnEscape=VbsUnEscape&ChrW(CLng("&H"&Mid(str,x+2,4)))

str=Mid(str,x+6)

Else

VbsUnEscape=VbsUnEscape&Chr(CLng("&H"&Mid(str,x+1,2)))

str=Mid(str,x+3)

End If

x=InStr(str,"%")

Loop

VbsUnEscape=VbsUnEscape&str

End Function

%>

?ヤ釜婕?绀猴?

瀹㈡?風??椤?client.html

asp接收ajax亂碼_asp,jquery,ajax中文亂碼解決辦法

?绋?搴?浠g??

//jquery??post

$.post

(

'server.asp',

{

Act:'DoSubmit',

UserName:escape('瑗挎ゼ?鋒??'),//杩?琛?缂???

WebSite:'www.chinacms.org'

},

function(data)

{

alert(unescape(data));//瀵矽????版??杩?琛?瑙g??

}

);

???″?ㄧ??椤?server.asp

asp接收ajax亂碼_asp,jquery,ajax中文亂碼解決辦法

?绋?搴?浠g??

Response.Charset="gb2312"

Dim UserName,WebSite

If Request.Form("Act")="DoSubmit" Then

UserName=Request.Form("UserName")

WebSite =Request.Form("WebSite")

'?ㄦ???″?ㄧ??瑙g??

UserName=VbsUnEscape(UserName)//瑙g??

'澶????版??

'---???ユ?版??澶????ㄥ??

'?版??澶?????杈??猴?????bsEscape()缂???

'by www.chinacms.org

Response.Write VbsEscape(UserName)

End If

%>

??浜??幫?

asp接收ajax亂碼_asp,jquery,ajax中文亂碼解決辦法
asp接收ajax亂碼_asp,jquery,ajax中文亂碼解決辦法

2008-12-20 16:25

娴?瑙? 3790

璇?璁?