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"]);
您可能感兴趣的文章:
- aspx实现的 jquery ui 的 flexgrid demo
- 用juery的ajax方法调用aspx.cs页面中的webmethod方法示例
- jQuery ajax调用后台aspx后台文件的两种常见方法(不是ashx)
本文由 华域联盟 原创撰写:华域联盟 » asp.net中在用ajax格式传递数据到aspx页面时出现乱码
转载请保留出处和原文链接:https://www.cnhackhy.com/46048.htm