In asp.net garbled code appears when transferring data in ajax format to the aspx page

  • 2020-05-19 04:38:43
  • OfStack

In asp.net, when transferring data in ajax format to aspx page, there will be some garble. The following is the solution

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

In test. aspx in:
 
string QueryName = HttpUtility.UrlDecode(Request.Params["QueryName"]); 
string QuerySex = HttpUtility.UrlDecode(Request.Params["QuerySex"]); 

Related articles: