52,798
社区成员
发帖
与我相关
我的任务
分享
xhr.open("post","动态页",true);
xhr.setRequestHeader("content-type","application/x-www-url-encoded");//注意要在open后才能调用setRequestHeader
string v=Request.Form["键"];
xhr.open("post","test.aspx",true);
xhr.setRequestHeader("content-type","application/x-www-url-encoded");
xhr.send("123456789");
string v=Request.Form.ToString();//得到123456789
xhr.open("post","test.aspx",true);
xhr.send("123456789");
if (Request.InputStream.Length > 0){
System.IO.StreamReader reader
= new System.IO.StreamReader(Request.InputStream);//注意如果必要时可以指定编码值,防止出现乱码
string v=reader.ReadToEnd();//值为123456789
reader.Close();
}
xhr.open("post","test.aspx?m=MM",true);
xhr.setRequestHeader("content-type","application/x-www-url-encoded");
xhr.send("123456789");
string v=Request.Form.ToString();//得到123456789
string m=Request.QueryString["m"];//得到MM
<%@ Page language="C#" ValidateRequest="false"%>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
System.Xml.XmlDocument doc = null;
if (Request.InputStream.Length > 0)//非 application/x-www-form-urlencoded类型
{
System.IO.StreamReader reader = new System.IO.StreamReader(Request.InputStream);
doc = new System.Xml.XmlDocument();
doc.LoadXml(reader.ReadToEnd());
reader.Close();
}
if (Request.Form.Count > 0)// application/x-www-form-urlencoded类型
{
doc = new System.Xml.XmlDocument();
doc.LoadXml(Server.UrlDecode(Request.Form.ToString()));
}
if (doc != null)
{
Response.Write(doc.GetElementsByTagName("item")[0].InnerText + "\n" + Request.QueryString["m"]);
Response.End();
}
}
</script>
<script type="text/javascript">
var xhr=new ActiveXObject("microsoft.xmlhttp");
xhr.open("post","alexa.aspx?m=MM",true)
//xhr.setRequestHeader("Content-Type", "text/plain");
//xhr.setRequestHeader("content-type","application/x-www-form-urlencoded")
xhr.send("<root><item>1</item></root>");
xhr.onreadystatechange=function(){
if(xhr.readyState==4)alert(xhr.responseText)
}
</script>