欢迎您访问新疆栾骏商贸有限公司,公司主营电子五金轴承产品批发业务!
全国咨询热线: 400-8878-609

新闻资讯

常见问题

asp.net中在用ajax格式传递数据到aspx页面时出现乱码

作者:用户投稿2026-01-11 13:03:40
asp.net中在用ajax格式传递数据到aspx页面时有时会出现乱码,以下为解决方法

js中
复制代码 代码如下:
XmlHttp.open("POST", "test.aspx", false);
XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XmlHttp.send("QueryName=" + escape(Queryname) + "&QuerySex=" +escape(Querysex));

在test.aspx中
复制代码 代码如下:
string QueryName = HttpUtility.UrlDecode(Request.Params["QueryName"]);
string QuerySex = HttpUtility.UrlDecode(Request.Params["QuerySex"]);