有关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"]);
   
    这样获取到的数据就不会出现乱码了更多http://jaiaiifh.blog.51cto.com

posted @ 2012-07-24 10:09  程序英才  阅读(108)  评论(0)    收藏  举报