码迷,mamicode.com
首页 > Web开发 > 详细

jquery ajax asp.net

时间:2015-08-05 18:00:46      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

function yanzhengma() {
var msgma = $("#txtma").val();
$.ajax({

type: "Post",
url: "WebForm3.aspx/RequestMethod2",
data: "{‘msg‘:‘" + msgma + "‘}",
contentType: "application/json;charset=utf-8", // 这句可不要忘了。
dataType: "json",
success: function (res) {
alert(res.d); // 注意有个d,至于为什么通过chrome看响应吧,O(∩_∩)O。
},
error: function (xmlReq, err, c) {
alert(err);
}
});
}

 

<input type ="text" id="txtma" />
<input type ="button" onclick="yanzhengma()" value="确定" />

 

[WebMethod]
public static string RequestMethod2(string msg)
{
try
{
string ma = HttpContext.Current.Session["ma"].ToString();
if (ma == msg)
{
return "yes";
}
else
{
return "no";
}
}
catch
{
return "您还没有发送短信验证码,或已过期";
}
}

jquery ajax asp.net

标签:

原文地址:http://www.cnblogs.com/waiwai1015/p/4705060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!