js
var xhr = new XMLHttpRequest(); xhr.open("post", "/Home/NoParamTest", true); //两种协议都可以 xhr.setRequestHeader("Content-Type", "application/json"); //xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(JSON.stringify({ a: 1, b: 2, c: 3 }));
c#后台
public void NoParamTest() { using (StreamReader sr = new StreamReader(Request.InputStream)) { //data就是前面传过来的数据 string data = sr.ReadLine(); } }
时间: 2024-10-10 17:28:59