C# Asp.net 获取不到ajax提交的form表单
Form表单<formid="form1"class="register-form"><inputtype="text"placeholder="用户名"id="r_us...
Form表单
<form id="form1" class="register-form">
<input type="text" placeholder="用户名" id="r_user_name" name="r_user_name"/>
<input type="password" placeholder="密码" id="r_password" />
<input type="text" placeholder="姓名" id="r_queryname" />
<button id="create">创建账户</button>
</form>
Ajax提交
$.ajax({
url: "Login.aspx/SetLoginon",
contentType: "application/json; charset=utf-8",
type: "POST",
data: $('#form1').serialize,
success: function (result) {
alert("succ")
}
})
[WebMethod]
public static string SetLoginon() {
string Data = HttpContext.Current.Request.Form.Get("r_user_name");
//到这里就获取不到任何参数了
return "false";
} 展开
<form id="form1" class="register-form">
<input type="text" placeholder="用户名" id="r_user_name" name="r_user_name"/>
<input type="password" placeholder="密码" id="r_password" />
<input type="text" placeholder="姓名" id="r_queryname" />
<button id="create">创建账户</button>
</form>
Ajax提交
$.ajax({
url: "Login.aspx/SetLoginon",
contentType: "application/json; charset=utf-8",
type: "POST",
data: $('#form1').serialize,
success: function (result) {
alert("succ")
}
})
[WebMethod]
public static string SetLoginon() {
string Data = HttpContext.Current.Request.Form.Get("r_user_name");
//到这里就获取不到任何参数了
return "false";
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询