Client page: client.html
Copy Code code as follows:
<script>
The post of jquery
$.post
(
' Server.asp ',
{
ACT: ' Dosubmit ',
Username:escape (' cloud-dwelling Community '),//coding
WebSite: ' Www.jb51.net '
},
function (data)
{
Alert (unescape (data));//decode the returned data
}
);
</script>
Server Side page: server.asp
Copy Code code as follows:
<%
response.charset= "gb2312"
Dim Username,website
If Request.Form ("Act") = "Dosubmit" Then
Username=request.form ("UserName")
WebSite =request.form ("WebSite")
' Decoding on the server side
Username=vbsunescape (UserName)//decoding
' Process data
'---Omit the data Processing Section
' Data processing after output, first with vbsescape () encoding
Response.Write Vbsescape (UserName)
End If
%>
<%
' is equivalent to escape () in JavaScript
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
' is equivalent to unescape () in JavaScript
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
%>
The Escape () function in JavaScript encodes the string so that it can be read on all computers.
You can use Unescape () to decode an escape () encoded string.
In fact, the ASP in these two functions are also working, incredibly many ASP site did not introduce.
Otherwise, you can decode the code by writing the function just like the above. Complex and poorly performing.
Server-side page above: Server.asp can be written as:
Unescape () and Escape () functions in ASP
Copy Code code as follows:
<%
response.charset= "gb2312"
Dim Username,website
If Request.Form ("Act") = "Dosubmit" Then
Username=request.form ("UserName")
WebSite =request.form ("WebSite")
' Decoding on the server side
Username=unescape (UserName)//decoding
' Process data
'---Omit the data Processing Section
' Data processing after output, first with vbsescape () encoding
Response.Write Escape (UserName)
End If
%>
That's a lot easier.