http://www.cnblogs.com/lyl6796910/archive/2011/11/24/2461333.html
js解码与编码和服务器端的解码与编码
服务器端:
Server.UrlEncode()方法对Url进行编码
Server.UrlDecode()方法 对url进行解码
Js方法:
escape() 函数可对字符串进行编码;
unescape() 函数可对字符串进行解码;
定义和用法
unescape() 函数可对通过 escape() 编码的字符串进行解码。
定义和用法
escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。
简单例子:
js编码:
Var name= escape ($(“#txtname”).value());
var strurl =login.aspx+ "?opt=add&companyname=" + name ;
$.ajax({
type: "POST",
cache: true,
url: strurl,
data: "opt=skip",
success: function (json) {
//成功方法
},
error: function (e) { }
});
解码:服务器端的解码简单:
String name= Server.UrlDecode(Request.QueryString["companyname "].ToString());