当前位置:编程学习 > asp >>

asp.net 中 ajax 传递数据出现乱码的问题

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"]);

 

这样获取到的数据就不会出现乱码了

 

摘自  秋之白桦
 
补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,