$.ajax({
type: "POST",
contentType: "application/json",
dataType: "json",
url: URL,
data: "name=bb", // 你那样也行
success: function (msg) {
},
error: function (msg) {
}
});
后台ashx.cs
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
string name = context.Request["name"]; //POST提交的数据
}
post的数据会提交一个字节流到对应的请求页,请求页通过读取字节流来获取post的数据!
示例C#中如何在后台获取post的数据:
System.IO.StreamReader sdr = new System.IO.StreamReader(Request.InputStream);
data = sdr.ReadToEnd();
你bb是变量还是值?
data: {name:bb},//bb是变量
data: {name:“bb”}, //bb是值
或者
data: "name=bb",
data: "name="+bb,
你Response.Write有没?